diff --git a/sdk/storage/azure-mgmt-storage/CHANGELOG.md b/sdk/storage/azure-mgmt-storage/CHANGELOG.md index 5e3e7c491c37..c84684bef814 100644 --- a/sdk/storage/azure-mgmt-storage/CHANGELOG.md +++ b/sdk/storage/azure-mgmt-storage/CHANGELOG.md @@ -1,5 +1,26 @@ # Release History +## 21.2.0 (2024-06-17) + +### Features Added + + - Added operation group NetworkSecurityPerimeterConfigurationsOperations + - Added operation group StorageTaskAssignmentInstancesReportOperations + - Added operation group StorageTaskAssignmentsInstancesReportOperations + - Added operation group StorageTaskAssignmentsOperations + - Model LocalUser has a new parameter allow_acl_authorization + - Model LocalUser has a new parameter extended_groups + - Model LocalUser has a new parameter group_id + - Model LocalUser has a new parameter is_nf_sv3_enabled + - Model LocalUser has a new parameter user_id + - Model LocalUsers has a new parameter next_link + - Model StorageAccount has a new parameter enable_extended_groups + - Model StorageAccountCreateParameters has a new parameter enable_extended_groups + - Model StorageAccountUpdateParameters has a new parameter enable_extended_groups + - Operation LocalUsersOperations.list has a new optional parameter filter + - Operation LocalUsersOperations.list has a new optional parameter include + - Operation LocalUsersOperations.list has a new optional parameter maxpagesize + ## 21.1.0 (2023-08-18) ### Features Added diff --git a/sdk/storage/azure-mgmt-storage/README.md b/sdk/storage/azure-mgmt-storage/README.md index fec1e9efd851..3d5a224cdf03 100644 --- a/sdk/storage/azure-mgmt-storage/README.md +++ b/sdk/storage/azure-mgmt-storage/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Storage Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-storage%2FREADME.png) diff --git a/sdk/storage/azure-mgmt-storage/_meta.json b/sdk/storage/azure-mgmt-storage/_meta.json index b8f1549abb7e..90edcab4ff15 100644 --- a/sdk/storage/azure-mgmt-storage/_meta.json +++ b/sdk/storage/azure-mgmt-storage/_meta.json @@ -1,12 +1,12 @@ { - "commit": "a3089b2764df11b10a8a43e2a5a33dbe4d3653ca", + "commit": "b22c642b361e6d6e7d72a2347a09b0bcf6075d70", "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.13.16", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/storage/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/storage/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.13.16 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/storage/resource-manager/readme.md", "package-2023-01": "2023-07-20 11:56:40 -0700 3e6b4ddca225530c27273d0f816466a905c0151b Microsoft.Storage/stable/2023-01-01/table.json", "package-2022-09": "2022-11-13 19:43:16 -0800 da0cfefaa0e6c237e1e3819f1cb2e11d7606878d Microsoft.Storage/stable/2022-09-01/table.json", @@ -28,5 +28,6 @@ "package-2017-06": "2019-06-26 12:38:19 -0400 26df0a691d94445b2c96d348f5ecc31f6f9a2099 Microsoft.Storage/stable/2017-06-01/storage.json", "package-2016-12": "2020-05-21 10:20:08 +0200 db0f437ba79086e20570d648fe932c4266e7a7ed Microsoft.Storage/stable/2016-12-01/storage.json", "package-2016-01": "2019-06-26 12:38:19 -0400 26df0a691d94445b2c96d348f5ecc31f6f9a2099 Microsoft.Storage/stable/2016-01-01/storage.json", - "package-2015-06": "2019-06-26 12:38:19 -0400 26df0a691d94445b2c96d348f5ecc31f6f9a2099 Microsoft.Storage/stable/2015-06-15/storage.json" + "package-2015-06": "2019-06-26 12:38:19 -0400 26df0a691d94445b2c96d348f5ecc31f6f9a2099 Microsoft.Storage/stable/2015-06-15/storage.json", + "package-2023-05": "2024-06-04 20:39:42 -0700 09c187c9589a143a477ed02c6639e914a4818179 Microsoft.Storage/stable/2023-05-01/storageTaskAssignments.json" } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py index a5f69131ed0d..7980191b56a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py @@ -10,7 +10,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 @@ -20,7 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration: """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(StorageManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-storage/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py index a00658b1fc19..75e26c415d2c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_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,7 @@ 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 raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +170,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 +288,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 +333,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 +344,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, @@ -392,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): @@ -417,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( @@ -447,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): @@ -547,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, @@ -563,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 @@ -651,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 @@ -670,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 @@ -712,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) @@ -732,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: @@ -746,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 """ @@ -755,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) @@ -806,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) @@ -826,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) @@ -999,7 +993,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) @@ -1176,10 +1170,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): @@ -1215,7 +1209,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:]) @@ -1236,7 +1229,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:]) @@ -1377,7 +1369,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, @@ -1397,7 +1389,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 @@ -1450,7 +1442,7 @@ 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) @@ -1487,7 +1479,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) @@ -1521,14 +1513,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 @@ -1584,7 +1576,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 @@ -1658,7 +1650,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) @@ -1706,7 +1698,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: @@ -1763,7 +1755,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"]: @@ -1814,7 +1806,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: @@ -1868,10 +1859,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): @@ -1899,7 +1890,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 @@ -1916,7 +1907,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): @@ -1951,7 +1942,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 @@ -1988,7 +1979,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 @@ -2004,9 +1995,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/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py index 910e24eb4bde..c886e7068b13 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py @@ -11,7 +11,9 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline import policies from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -53,7 +55,7 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-01' + DEFAULT_API_VERSION = '2023-05-01' _PROFILE_TAG = "azure.mgmt.storage.StorageManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -75,7 +77,25 @@ def __init__( if api_version: kwargs.setdefault('api_version', api_version) self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = 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(base_url=base_url, policies=_policies, **kwargs) super(StorageManagementClient, self).__init__( api_version=api_version, profile=profile @@ -110,6 +130,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-05-01: :mod:`v2022_05_01.models` * 2022-09-01: :mod:`v2022_09_01.models` * 2023-01-01: :mod:`v2023_01_01.models` + * 2023-05-01: :mod:`v2023_05_01.models` """ if api_version == '2015-06-15': from .v2015_06_15 import models @@ -174,6 +195,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2023-01-01': from .v2023_01_01 import models return models + elif api_version == '2023-05-01': + from .v2023_05_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -196,6 +220,7 @@ def blob_containers(self): * 2022-05-01: :class:`BlobContainersOperations` * 2022-09-01: :class:`BlobContainersOperations` * 2023-01-01: :class:`BlobContainersOperations` + * 2023-05-01: :class:`BlobContainersOperations` """ api_version = self._get_api_version('blob_containers') if api_version == '2018-02-01': @@ -230,6 +255,8 @@ def blob_containers(self): from .v2022_09_01.operations import BlobContainersOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import BlobContainersOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import BlobContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_containers'".format(api_version)) self._config.api_version = api_version @@ -250,6 +277,7 @@ def blob_inventory_policies(self): * 2022-05-01: :class:`BlobInventoryPoliciesOperations` * 2022-09-01: :class:`BlobInventoryPoliciesOperations` * 2023-01-01: :class:`BlobInventoryPoliciesOperations` + * 2023-05-01: :class:`BlobInventoryPoliciesOperations` """ api_version = self._get_api_version('blob_inventory_policies') if api_version == '2019-06-01': @@ -274,6 +302,8 @@ def blob_inventory_policies(self): from .v2022_09_01.operations import BlobInventoryPoliciesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import BlobInventoryPoliciesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import BlobInventoryPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_inventory_policies'".format(api_version)) self._config.api_version = api_version @@ -297,6 +327,7 @@ def blob_services(self): * 2022-05-01: :class:`BlobServicesOperations` * 2022-09-01: :class:`BlobServicesOperations` * 2023-01-01: :class:`BlobServicesOperations` + * 2023-05-01: :class:`BlobServicesOperations` """ api_version = self._get_api_version('blob_services') if api_version == '2018-07-01': @@ -327,6 +358,8 @@ def blob_services(self): from .v2022_09_01.operations import BlobServicesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import BlobServicesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import BlobServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_services'".format(api_version)) self._config.api_version = api_version @@ -346,6 +379,7 @@ def deleted_accounts(self): * 2022-05-01: :class:`DeletedAccountsOperations` * 2022-09-01: :class:`DeletedAccountsOperations` * 2023-01-01: :class:`DeletedAccountsOperations` + * 2023-05-01: :class:`DeletedAccountsOperations` """ api_version = self._get_api_version('deleted_accounts') if api_version == '2020-08-01-preview': @@ -368,6 +402,8 @@ def deleted_accounts(self): from .v2022_09_01.operations import DeletedAccountsOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import DeletedAccountsOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import DeletedAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deleted_accounts'".format(api_version)) self._config.api_version = api_version @@ -388,6 +424,7 @@ def encryption_scopes(self): * 2022-05-01: :class:`EncryptionScopesOperations` * 2022-09-01: :class:`EncryptionScopesOperations` * 2023-01-01: :class:`EncryptionScopesOperations` + * 2023-05-01: :class:`EncryptionScopesOperations` """ api_version = self._get_api_version('encryption_scopes') if api_version == '2019-06-01': @@ -412,6 +449,8 @@ def encryption_scopes(self): from .v2022_09_01.operations import EncryptionScopesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import EncryptionScopesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import EncryptionScopesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'encryption_scopes'".format(api_version)) self._config.api_version = api_version @@ -433,6 +472,7 @@ def file_services(self): * 2022-05-01: :class:`FileServicesOperations` * 2022-09-01: :class:`FileServicesOperations` * 2023-01-01: :class:`FileServicesOperations` + * 2023-05-01: :class:`FileServicesOperations` """ api_version = self._get_api_version('file_services') if api_version == '2019-04-01': @@ -459,6 +499,8 @@ def file_services(self): from .v2022_09_01.operations import FileServicesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import FileServicesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import FileServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_services'".format(api_version)) self._config.api_version = api_version @@ -480,6 +522,7 @@ def file_shares(self): * 2022-05-01: :class:`FileSharesOperations` * 2022-09-01: :class:`FileSharesOperations` * 2023-01-01: :class:`FileSharesOperations` + * 2023-05-01: :class:`FileSharesOperations` """ api_version = self._get_api_version('file_shares') if api_version == '2019-04-01': @@ -506,6 +549,8 @@ def file_shares(self): from .v2022_09_01.operations import FileSharesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import FileSharesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import FileSharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_shares'".format(api_version)) self._config.api_version = api_version @@ -520,6 +565,7 @@ def local_users(self): * 2022-05-01: :class:`LocalUsersOperations` * 2022-09-01: :class:`LocalUsersOperations` * 2023-01-01: :class:`LocalUsersOperations` + * 2023-05-01: :class:`LocalUsersOperations` """ api_version = self._get_api_version('local_users') if api_version == '2021-08-01': @@ -532,6 +578,8 @@ def local_users(self): from .v2022_09_01.operations import LocalUsersOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import LocalUsersOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import LocalUsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'local_users'".format(api_version)) self._config.api_version = api_version @@ -555,6 +603,7 @@ def management_policies(self): * 2022-05-01: :class:`ManagementPoliciesOperations` * 2022-09-01: :class:`ManagementPoliciesOperations` * 2023-01-01: :class:`ManagementPoliciesOperations` + * 2023-05-01: :class:`ManagementPoliciesOperations` """ api_version = self._get_api_version('management_policies') if api_version == '2018-03-01-preview': @@ -585,11 +634,27 @@ def management_policies(self): from .v2022_09_01.operations import ManagementPoliciesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import ManagementPoliciesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import ManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'management_policies'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property + def network_security_perimeter_configurations(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`NetworkSecurityPerimeterConfigurationsOperations` + """ + api_version = self._get_api_version('network_security_perimeter_configurations') + if api_version == '2023-05-01': + from .v2023_05_01.operations import NetworkSecurityPerimeterConfigurationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'network_security_perimeter_configurations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property def object_replication_policies(self): """Instance depends on the API version: @@ -605,6 +670,7 @@ def object_replication_policies(self): * 2022-05-01: :class:`ObjectReplicationPoliciesOperations` * 2022-09-01: :class:`ObjectReplicationPoliciesOperations` * 2023-01-01: :class:`ObjectReplicationPoliciesOperations` + * 2023-05-01: :class:`ObjectReplicationPoliciesOperations` """ api_version = self._get_api_version('object_replication_policies') if api_version == '2019-06-01': @@ -629,6 +695,8 @@ def object_replication_policies(self): from .v2022_09_01.operations import ObjectReplicationPoliciesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import ObjectReplicationPoliciesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import ObjectReplicationPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'object_replication_policies'".format(api_version)) self._config.api_version = api_version @@ -656,6 +724,7 @@ def operations(self): * 2022-05-01: :class:`Operations` * 2022-09-01: :class:`Operations` * 2023-01-01: :class:`Operations` + * 2023-05-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-06-01': @@ -694,6 +763,8 @@ def operations(self): from .v2022_09_01.operations import Operations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import Operations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version @@ -714,6 +785,7 @@ def private_endpoint_connections(self): * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` * 2022-09-01: :class:`PrivateEndpointConnectionsOperations` * 2023-01-01: :class:`PrivateEndpointConnectionsOperations` + * 2023-05-01: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-06-01': @@ -738,6 +810,8 @@ def private_endpoint_connections(self): from .v2022_09_01.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) self._config.api_version = api_version @@ -758,6 +832,7 @@ def private_link_resources(self): * 2022-05-01: :class:`PrivateLinkResourcesOperations` * 2022-09-01: :class:`PrivateLinkResourcesOperations` * 2023-01-01: :class:`PrivateLinkResourcesOperations` + * 2023-05-01: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2019-06-01': @@ -782,6 +857,8 @@ def private_link_resources(self): from .v2022_09_01.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) self._config.api_version = api_version @@ -802,6 +879,7 @@ def queue(self): * 2022-05-01: :class:`QueueOperations` * 2022-09-01: :class:`QueueOperations` * 2023-01-01: :class:`QueueOperations` + * 2023-05-01: :class:`QueueOperations` """ api_version = self._get_api_version('queue') if api_version == '2019-06-01': @@ -826,6 +904,8 @@ def queue(self): from .v2022_09_01.operations import QueueOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import QueueOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import QueueOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue'".format(api_version)) self._config.api_version = api_version @@ -846,6 +926,7 @@ def queue_services(self): * 2022-05-01: :class:`QueueServicesOperations` * 2022-09-01: :class:`QueueServicesOperations` * 2023-01-01: :class:`QueueServicesOperations` + * 2023-05-01: :class:`QueueServicesOperations` """ api_version = self._get_api_version('queue_services') if api_version == '2019-06-01': @@ -870,6 +951,8 @@ def queue_services(self): from .v2022_09_01.operations import QueueServicesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import QueueServicesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import QueueServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue_services'".format(api_version)) self._config.api_version = api_version @@ -897,6 +980,7 @@ def skus(self): * 2022-05-01: :class:`SkusOperations` * 2022-09-01: :class:`SkusOperations` * 2023-01-01: :class:`SkusOperations` + * 2023-05-01: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2017-06-01': @@ -935,6 +1019,8 @@ def skus(self): from .v2022_09_01.operations import SkusOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import SkusOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) self._config.api_version = api_version @@ -965,6 +1051,7 @@ def storage_accounts(self): * 2022-05-01: :class:`StorageAccountsOperations` * 2022-09-01: :class:`StorageAccountsOperations` * 2023-01-01: :class:`StorageAccountsOperations` + * 2023-05-01: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') if api_version == '2015-06-15': @@ -1009,11 +1096,55 @@ def storage_accounts(self): from .v2022_09_01.operations import StorageAccountsOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import StorageAccountsOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property + def storage_task_assignment_instances_report(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`StorageTaskAssignmentInstancesReportOperations` + """ + api_version = self._get_api_version('storage_task_assignment_instances_report') + if api_version == '2023-05-01': + from .v2023_05_01.operations import StorageTaskAssignmentInstancesReportOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'storage_task_assignment_instances_report'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def storage_task_assignments(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`StorageTaskAssignmentsOperations` + """ + api_version = self._get_api_version('storage_task_assignments') + if api_version == '2023-05-01': + from .v2023_05_01.operations import StorageTaskAssignmentsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'storage_task_assignments'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def storage_task_assignments_instances_report(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`StorageTaskAssignmentsInstancesReportOperations` + """ + api_version = self._get_api_version('storage_task_assignments_instances_report') + if api_version == '2023-05-01': + from .v2023_05_01.operations import StorageTaskAssignmentsInstancesReportOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'storage_task_assignments_instances_report'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property def table(self): """Instance depends on the API version: @@ -1029,6 +1160,7 @@ def table(self): * 2022-05-01: :class:`TableOperations` * 2022-09-01: :class:`TableOperations` * 2023-01-01: :class:`TableOperations` + * 2023-05-01: :class:`TableOperations` """ api_version = self._get_api_version('table') if api_version == '2019-06-01': @@ -1053,6 +1185,8 @@ def table(self): from .v2022_09_01.operations import TableOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import TableOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import TableOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table'".format(api_version)) self._config.api_version = api_version @@ -1073,6 +1207,7 @@ def table_services(self): * 2022-05-01: :class:`TableServicesOperations` * 2022-09-01: :class:`TableServicesOperations` * 2023-01-01: :class:`TableServicesOperations` + * 2023-05-01: :class:`TableServicesOperations` """ api_version = self._get_api_version('table_services') if api_version == '2019-06-01': @@ -1097,6 +1232,8 @@ def table_services(self): from .v2022_09_01.operations import TableServicesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import TableServicesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import TableServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table_services'".format(api_version)) self._config.api_version = api_version @@ -1150,6 +1287,7 @@ def usages(self): * 2022-05-01: :class:`UsagesOperations` * 2022-09-01: :class:`UsagesOperations` * 2023-01-01: :class:`UsagesOperations` + * 2023-05-01: :class:`UsagesOperations` """ api_version = self._get_api_version('usages') if api_version == '2018-03-01-preview': @@ -1182,6 +1320,8 @@ def usages(self): from .v2022_09_01.operations import UsagesOperations as OperationClass elif api_version == '2023-01-01': from .v2023_01_01.operations import UsagesOperations as OperationClass + elif api_version == '2023-05-01': + from .v2023_05_01.operations import UsagesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usages'".format(api_version)) self._config.api_version = api_version diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py index 81607c2c308a..ba461663481e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py index d32952689272..162af7abb283 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py @@ -10,7 +10,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 @@ -20,7 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration: """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(StorageManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-storage/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py index bfddfbafb4db..7b8be2ef1c9d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py @@ -11,7 +11,9 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline import policies from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -53,7 +55,7 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-01' + DEFAULT_API_VERSION = '2023-05-01' _PROFILE_TAG = "azure.mgmt.storage.StorageManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -75,7 +77,25 @@ def __init__( if api_version: kwargs.setdefault('api_version', api_version) self._config = StorageManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = 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(base_url=base_url, policies=_policies, **kwargs) super(StorageManagementClient, self).__init__( api_version=api_version, profile=profile @@ -110,6 +130,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-05-01: :mod:`v2022_05_01.models` * 2022-09-01: :mod:`v2022_09_01.models` * 2023-01-01: :mod:`v2023_01_01.models` + * 2023-05-01: :mod:`v2023_05_01.models` """ if api_version == '2015-06-15': from ..v2015_06_15 import models @@ -174,6 +195,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2023-01-01': from ..v2023_01_01 import models return models + elif api_version == '2023-05-01': + from ..v2023_05_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -196,6 +220,7 @@ def blob_containers(self): * 2022-05-01: :class:`BlobContainersOperations` * 2022-09-01: :class:`BlobContainersOperations` * 2023-01-01: :class:`BlobContainersOperations` + * 2023-05-01: :class:`BlobContainersOperations` """ api_version = self._get_api_version('blob_containers') if api_version == '2018-02-01': @@ -230,6 +255,8 @@ def blob_containers(self): from ..v2022_09_01.aio.operations import BlobContainersOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import BlobContainersOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import BlobContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_containers'".format(api_version)) self._config.api_version = api_version @@ -250,6 +277,7 @@ def blob_inventory_policies(self): * 2022-05-01: :class:`BlobInventoryPoliciesOperations` * 2022-09-01: :class:`BlobInventoryPoliciesOperations` * 2023-01-01: :class:`BlobInventoryPoliciesOperations` + * 2023-05-01: :class:`BlobInventoryPoliciesOperations` """ api_version = self._get_api_version('blob_inventory_policies') if api_version == '2019-06-01': @@ -274,6 +302,8 @@ def blob_inventory_policies(self): from ..v2022_09_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_inventory_policies'".format(api_version)) self._config.api_version = api_version @@ -297,6 +327,7 @@ def blob_services(self): * 2022-05-01: :class:`BlobServicesOperations` * 2022-09-01: :class:`BlobServicesOperations` * 2023-01-01: :class:`BlobServicesOperations` + * 2023-05-01: :class:`BlobServicesOperations` """ api_version = self._get_api_version('blob_services') if api_version == '2018-07-01': @@ -327,6 +358,8 @@ def blob_services(self): from ..v2022_09_01.aio.operations import BlobServicesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import BlobServicesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import BlobServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_services'".format(api_version)) self._config.api_version = api_version @@ -346,6 +379,7 @@ def deleted_accounts(self): * 2022-05-01: :class:`DeletedAccountsOperations` * 2022-09-01: :class:`DeletedAccountsOperations` * 2023-01-01: :class:`DeletedAccountsOperations` + * 2023-05-01: :class:`DeletedAccountsOperations` """ api_version = self._get_api_version('deleted_accounts') if api_version == '2020-08-01-preview': @@ -368,6 +402,8 @@ def deleted_accounts(self): from ..v2022_09_01.aio.operations import DeletedAccountsOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import DeletedAccountsOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import DeletedAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deleted_accounts'".format(api_version)) self._config.api_version = api_version @@ -388,6 +424,7 @@ def encryption_scopes(self): * 2022-05-01: :class:`EncryptionScopesOperations` * 2022-09-01: :class:`EncryptionScopesOperations` * 2023-01-01: :class:`EncryptionScopesOperations` + * 2023-05-01: :class:`EncryptionScopesOperations` """ api_version = self._get_api_version('encryption_scopes') if api_version == '2019-06-01': @@ -412,6 +449,8 @@ def encryption_scopes(self): from ..v2022_09_01.aio.operations import EncryptionScopesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import EncryptionScopesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import EncryptionScopesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'encryption_scopes'".format(api_version)) self._config.api_version = api_version @@ -433,6 +472,7 @@ def file_services(self): * 2022-05-01: :class:`FileServicesOperations` * 2022-09-01: :class:`FileServicesOperations` * 2023-01-01: :class:`FileServicesOperations` + * 2023-05-01: :class:`FileServicesOperations` """ api_version = self._get_api_version('file_services') if api_version == '2019-04-01': @@ -459,6 +499,8 @@ def file_services(self): from ..v2022_09_01.aio.operations import FileServicesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import FileServicesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import FileServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_services'".format(api_version)) self._config.api_version = api_version @@ -480,6 +522,7 @@ def file_shares(self): * 2022-05-01: :class:`FileSharesOperations` * 2022-09-01: :class:`FileSharesOperations` * 2023-01-01: :class:`FileSharesOperations` + * 2023-05-01: :class:`FileSharesOperations` """ api_version = self._get_api_version('file_shares') if api_version == '2019-04-01': @@ -506,6 +549,8 @@ def file_shares(self): from ..v2022_09_01.aio.operations import FileSharesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import FileSharesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import FileSharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_shares'".format(api_version)) self._config.api_version = api_version @@ -520,6 +565,7 @@ def local_users(self): * 2022-05-01: :class:`LocalUsersOperations` * 2022-09-01: :class:`LocalUsersOperations` * 2023-01-01: :class:`LocalUsersOperations` + * 2023-05-01: :class:`LocalUsersOperations` """ api_version = self._get_api_version('local_users') if api_version == '2021-08-01': @@ -532,6 +578,8 @@ def local_users(self): from ..v2022_09_01.aio.operations import LocalUsersOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import LocalUsersOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import LocalUsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'local_users'".format(api_version)) self._config.api_version = api_version @@ -555,6 +603,7 @@ def management_policies(self): * 2022-05-01: :class:`ManagementPoliciesOperations` * 2022-09-01: :class:`ManagementPoliciesOperations` * 2023-01-01: :class:`ManagementPoliciesOperations` + * 2023-05-01: :class:`ManagementPoliciesOperations` """ api_version = self._get_api_version('management_policies') if api_version == '2018-03-01-preview': @@ -585,11 +634,27 @@ def management_policies(self): from ..v2022_09_01.aio.operations import ManagementPoliciesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import ManagementPoliciesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import ManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'management_policies'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property + def network_security_perimeter_configurations(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`NetworkSecurityPerimeterConfigurationsOperations` + """ + api_version = self._get_api_version('network_security_perimeter_configurations') + if api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import NetworkSecurityPerimeterConfigurationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'network_security_perimeter_configurations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property def object_replication_policies(self): """Instance depends on the API version: @@ -605,6 +670,7 @@ def object_replication_policies(self): * 2022-05-01: :class:`ObjectReplicationPoliciesOperations` * 2022-09-01: :class:`ObjectReplicationPoliciesOperations` * 2023-01-01: :class:`ObjectReplicationPoliciesOperations` + * 2023-05-01: :class:`ObjectReplicationPoliciesOperations` """ api_version = self._get_api_version('object_replication_policies') if api_version == '2019-06-01': @@ -629,6 +695,8 @@ def object_replication_policies(self): from ..v2022_09_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'object_replication_policies'".format(api_version)) self._config.api_version = api_version @@ -656,6 +724,7 @@ def operations(self): * 2022-05-01: :class:`Operations` * 2022-09-01: :class:`Operations` * 2023-01-01: :class:`Operations` + * 2023-05-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-06-01': @@ -694,6 +763,8 @@ def operations(self): from ..v2022_09_01.aio.operations import Operations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import Operations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version @@ -714,6 +785,7 @@ def private_endpoint_connections(self): * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` * 2022-09-01: :class:`PrivateEndpointConnectionsOperations` * 2023-01-01: :class:`PrivateEndpointConnectionsOperations` + * 2023-05-01: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-06-01': @@ -738,6 +810,8 @@ def private_endpoint_connections(self): from ..v2022_09_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) self._config.api_version = api_version @@ -758,6 +832,7 @@ def private_link_resources(self): * 2022-05-01: :class:`PrivateLinkResourcesOperations` * 2022-09-01: :class:`PrivateLinkResourcesOperations` * 2023-01-01: :class:`PrivateLinkResourcesOperations` + * 2023-05-01: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2019-06-01': @@ -782,6 +857,8 @@ def private_link_resources(self): from ..v2022_09_01.aio.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) self._config.api_version = api_version @@ -802,6 +879,7 @@ def queue(self): * 2022-05-01: :class:`QueueOperations` * 2022-09-01: :class:`QueueOperations` * 2023-01-01: :class:`QueueOperations` + * 2023-05-01: :class:`QueueOperations` """ api_version = self._get_api_version('queue') if api_version == '2019-06-01': @@ -826,6 +904,8 @@ def queue(self): from ..v2022_09_01.aio.operations import QueueOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import QueueOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import QueueOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue'".format(api_version)) self._config.api_version = api_version @@ -846,6 +926,7 @@ def queue_services(self): * 2022-05-01: :class:`QueueServicesOperations` * 2022-09-01: :class:`QueueServicesOperations` * 2023-01-01: :class:`QueueServicesOperations` + * 2023-05-01: :class:`QueueServicesOperations` """ api_version = self._get_api_version('queue_services') if api_version == '2019-06-01': @@ -870,6 +951,8 @@ def queue_services(self): from ..v2022_09_01.aio.operations import QueueServicesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import QueueServicesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import QueueServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue_services'".format(api_version)) self._config.api_version = api_version @@ -897,6 +980,7 @@ def skus(self): * 2022-05-01: :class:`SkusOperations` * 2022-09-01: :class:`SkusOperations` * 2023-01-01: :class:`SkusOperations` + * 2023-05-01: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2017-06-01': @@ -935,6 +1019,8 @@ def skus(self): from ..v2022_09_01.aio.operations import SkusOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import SkusOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) self._config.api_version = api_version @@ -965,6 +1051,7 @@ def storage_accounts(self): * 2022-05-01: :class:`StorageAccountsOperations` * 2022-09-01: :class:`StorageAccountsOperations` * 2023-01-01: :class:`StorageAccountsOperations` + * 2023-05-01: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') if api_version == '2015-06-15': @@ -1009,11 +1096,55 @@ def storage_accounts(self): from ..v2022_09_01.aio.operations import StorageAccountsOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import StorageAccountsOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property + def storage_task_assignment_instances_report(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`StorageTaskAssignmentInstancesReportOperations` + """ + api_version = self._get_api_version('storage_task_assignment_instances_report') + if api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import StorageTaskAssignmentInstancesReportOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'storage_task_assignment_instances_report'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def storage_task_assignments(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`StorageTaskAssignmentsOperations` + """ + api_version = self._get_api_version('storage_task_assignments') + if api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import StorageTaskAssignmentsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'storage_task_assignments'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def storage_task_assignments_instances_report(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`StorageTaskAssignmentsInstancesReportOperations` + """ + api_version = self._get_api_version('storage_task_assignments_instances_report') + if api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import StorageTaskAssignmentsInstancesReportOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'storage_task_assignments_instances_report'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + @property def table(self): """Instance depends on the API version: @@ -1029,6 +1160,7 @@ def table(self): * 2022-05-01: :class:`TableOperations` * 2022-09-01: :class:`TableOperations` * 2023-01-01: :class:`TableOperations` + * 2023-05-01: :class:`TableOperations` """ api_version = self._get_api_version('table') if api_version == '2019-06-01': @@ -1053,6 +1185,8 @@ def table(self): from ..v2022_09_01.aio.operations import TableOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import TableOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import TableOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table'".format(api_version)) self._config.api_version = api_version @@ -1073,6 +1207,7 @@ def table_services(self): * 2022-05-01: :class:`TableServicesOperations` * 2022-09-01: :class:`TableServicesOperations` * 2023-01-01: :class:`TableServicesOperations` + * 2023-05-01: :class:`TableServicesOperations` """ api_version = self._get_api_version('table_services') if api_version == '2019-06-01': @@ -1097,6 +1232,8 @@ def table_services(self): from ..v2022_09_01.aio.operations import TableServicesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import TableServicesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import TableServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table_services'".format(api_version)) self._config.api_version = api_version @@ -1150,6 +1287,7 @@ def usages(self): * 2022-05-01: :class:`UsagesOperations` * 2022-09-01: :class:`UsagesOperations` * 2023-01-01: :class:`UsagesOperations` + * 2023-05-01: :class:`UsagesOperations` """ api_version = self._get_api_version('usages') if api_version == '2018-03-01-preview': @@ -1182,6 +1320,8 @@ def usages(self): from ..v2022_09_01.aio.operations import UsagesOperations as OperationClass elif api_version == '2023-01-01': from ..v2023_01_01.aio.operations import UsagesOperations as OperationClass + elif api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import UsagesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usages'".format(api_version)) self._config.api_version = api_version diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py index 4d026ea07bcc..98fec195fcf7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- from .v2018_02_01.models import * -from .v2023_01_01.models import * +from .v2023_05_01.models import * diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py index 532728101b43..09db0170b783 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-15") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json index 68563c3de474..ba16009ace9d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "storage_accounts": "StorageAccountsOperations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py index 287a26fba083..777c2cd0a24f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -51,7 +53,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -62,7 +82,7 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2015-06-15") - 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 @@ -82,7 +102,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py index 6528c5e8a5dc..1b6493b10e64 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2015-06-15") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py index 7c177e7d7b16..826154c6ccd4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -52,7 +54,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -63,7 +83,9 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2015-06-15") - 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 @@ -83,7 +105,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py index 6ad6c38d0726..ba7e3fe72204 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -43,6 +44,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]] @@ -85,7 +90,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -93,18 +97,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -112,25 +115,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,22 +153,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -180,22 +179,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,7 +213,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -226,16 +221,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -249,13 +243,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -284,14 +274,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -304,7 +286,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -322,18 +304,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of cls(response) :rtype: @@ -346,7 +320,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -362,19 +336,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -407,7 +371,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -417,17 +381,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -442,12 +404,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,21 +422,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,11 +445,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -506,12 +462,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,21 +480,20 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -551,13 +505,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -590,7 +540,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -601,7 +550,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -623,11 +572,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -638,7 +586,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -658,17 +606,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -691,7 +636,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -699,16 +644,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -720,20 +664,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] @@ -745,7 +684,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -756,15 +695,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -775,14 +713,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -792,11 +730,11 @@ async def extract_data(pipeline_response): 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 @@ -808,8 +746,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -820,7 +756,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] @@ -832,7 +767,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,16 +778,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -863,14 +797,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -880,11 +814,11 @@ async def extract_data(pipeline_response): 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 @@ -896,10 +830,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccountKeys: """Lists the access keys for the specified storage account. @@ -911,12 +841,11 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -930,21 +859,20 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccountKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -956,13 +884,9 @@ async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -990,7 +914,6 @@ async def regenerate_key( :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: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -1001,7 +924,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1017,11 +940,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -1032,7 +954,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountKeys: """Regenerates one of the access keys for the specified storage account. @@ -1045,18 +967,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1079,7 +997,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1087,16 +1005,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1108,10 +1025,6 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py index 0d036150953a..832adc843ace 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usage_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Lists the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py index 9367dca1c6ae..c7c3218ea125 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py @@ -67,7 +67,7 @@ def __init__( class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: The custom domain name. Name is the CNAME source. Required. :vartype name: str @@ -339,10 +339,10 @@ def __init__( self.secondary_endpoints = secondary_endpoints -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. - 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 name: Required. :vartype name: str @@ -374,7 +374,7 @@ def __init__(self, *, name: str, type: str = "Microsoft.Storage/storageAccounts" class StorageAccountCreateParameters(_serialization.Model): """The parameters to provide for the account. - 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 location: The location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource @@ -481,7 +481,7 @@ def __init__(self, *, value: Optional[List["_models.StorageAccount"]] = None, ** class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: Required. :vartype key_name: str @@ -556,7 +556,7 @@ def __init__( class Usage(_serialization.Model): """Describes Storage Resource Usage. - 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 unit: The unit of measurement. Required. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", and "BytesPerSecond". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py index aeb33492a569..ed828ac2a2f9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -361,7 +366,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -369,18 +373,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -388,25 +391,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,22 +429,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,22 +455,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,7 +489,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -502,16 +497,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,13 +519,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -560,14 +550,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] @@ -579,7 +561,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -597,18 +579,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] @@ -620,7 +594,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -636,19 +610,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] @@ -680,7 +644,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -690,17 +654,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -715,12 +677,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -734,21 +695,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -758,11 +718,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -777,12 +733,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -796,21 +751,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -822,13 +776,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -861,7 +811,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -872,7 +821,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -894,11 +843,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -909,7 +857,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -929,17 +877,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -962,7 +907,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -970,16 +915,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -991,20 +935,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1015,7 +954,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1026,15 +965,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1045,14 +983,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1062,11 +1000,11 @@ def extract_data(pipeline_response): 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 @@ -1078,8 +1016,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1088,7 +1024,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1099,7 +1034,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1110,16 +1045,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1130,14 +1064,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1147,11 +1081,11 @@ def extract_data(pipeline_response): 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 @@ -1163,10 +1097,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccountKeys: """Lists the access keys for the specified storage account. @@ -1178,12 +1108,11 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1197,21 +1126,20 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.StorageAccountKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1223,13 +1151,9 @@ def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1257,7 +1181,6 @@ def regenerate_key( :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: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -1268,7 +1191,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1284,11 +1207,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -1299,7 +1221,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountKeys: """Regenerates one of the access keys for the specified storage account. @@ -1312,18 +1234,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1346,7 +1264,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1354,16 +1272,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1375,10 +1292,6 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py index 669238bf6218..6dd8e11adf0a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Lists the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-15")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py index 590be2e288c7..0311eb048776 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2016-01-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json index de745a71ba7b..b49e8562233a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "storage_accounts": "StorageAccountsOperations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py index 7683139749df..57ba78f99452 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -53,7 +55,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -64,7 +84,7 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2016-01-01") - 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 @@ -84,7 +104,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py index 85aaf4cfefb4..c855fa5f21b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2016-01-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py index 0d78ff6c0840..e01f6ceeb104 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -54,7 +56,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -65,7 +85,9 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2016-01-01") - 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 @@ -85,7 +107,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py index 0924059b8ece..d48b50887736 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -43,6 +44,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]] @@ -85,7 +90,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -93,18 +97,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -112,25 +115,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,22 +153,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -180,22 +179,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,7 +213,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -226,16 +221,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -249,13 +243,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -284,14 +274,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -304,7 +286,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -322,18 +304,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of cls(response) :rtype: @@ -346,7 +320,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -362,19 +336,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -407,7 +371,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -417,17 +381,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -442,12 +404,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,21 +422,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,11 +445,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -506,12 +462,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,21 +480,20 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -551,13 +505,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -590,7 +540,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -601,7 +550,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -623,11 +572,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -638,7 +586,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -658,17 +606,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -691,7 +636,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -699,16 +644,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -720,20 +664,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] @@ -745,7 +684,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -756,15 +695,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -775,14 +713,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -792,11 +730,11 @@ async def extract_data(pipeline_response): 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 @@ -808,8 +746,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -820,7 +756,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] @@ -832,7 +767,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,16 +778,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -863,14 +797,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -880,11 +814,11 @@ async def extract_data(pipeline_response): 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 @@ -896,10 +830,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -913,12 +843,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -932,21 +861,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -958,13 +886,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -992,7 +916,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1003,7 +926,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1019,11 +942,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1034,7 +956,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1047,18 +969,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1081,7 +999,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1089,16 +1007,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1110,10 +1027,6 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py index 9c26bdf8e3a9..9c5b1fd952bb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usage_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py index 535b225d2ef8..3267ab956a8c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py @@ -56,7 +56,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -92,7 +92,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2016_01_01.models.EncryptionServices @@ -274,7 +274,7 @@ class Sku(_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 name: Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Required. Known values are: @@ -434,10 +434,10 @@ def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, s self.access_tier = None -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """StorageAccountCheckNameAvailabilityParameters. - 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 name: Required. :vartype name: str @@ -474,7 +474,7 @@ def __init__( class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku @@ -652,7 +652,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """StorageAccountRegenerateKeyParameters. - 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 key_name: Required. :vartype key_name: str diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py index a58906069952..fff2005955c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -347,7 +352,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -355,18 +359,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -374,25 +377,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -415,22 +415,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -442,22 +441,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -480,7 +475,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -488,16 +483,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -511,13 +505,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -546,14 +536,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] @@ -565,7 +547,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -583,18 +565,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] @@ -606,7 +580,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -622,19 +596,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] @@ -666,7 +630,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -676,17 +640,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -701,12 +663,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,21 +681,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -744,11 +704,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -763,12 +719,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -782,21 +737,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -808,13 +762,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -847,7 +797,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -858,7 +807,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -880,11 +829,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -895,7 +843,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -915,17 +863,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -948,7 +893,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -956,16 +901,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -977,20 +921,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1001,7 +940,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1012,15 +951,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1031,14 +969,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1048,11 +986,11 @@ def extract_data(pipeline_response): 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 @@ -1064,8 +1002,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1074,7 +1010,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1085,7 +1020,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1096,16 +1031,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1116,14 +1050,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1133,11 +1067,11 @@ def extract_data(pipeline_response): 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 @@ -1149,10 +1083,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1166,12 +1096,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,21 +1114,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1211,13 +1139,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1245,7 +1169,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1256,7 +1179,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1272,11 +1195,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1287,7 +1209,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1300,18 +1222,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1334,7 +1252,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1342,16 +1260,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1363,10 +1280,6 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py index dd4ee9bfc4c2..54c5a4026a5e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-01-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py index 993eedb898b7..3039798df557 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2016-12-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json index 06e98a66f892..8f1101556fc6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "storage_accounts": "StorageAccountsOperations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py index 809c2580f57f..769d635425fc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -51,7 +53,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -62,7 +82,7 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2016-12-01") - 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 @@ -82,7 +102,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py index a3e49adc277f..2aca0751aec4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2016-12-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py index 90da15e898d2..644c89ba9a94 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -52,7 +54,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -63,7 +83,9 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2016-12-01") - 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 @@ -83,7 +105,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py index 24bab7dd791c..18293a865192 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -87,7 +92,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +99,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -114,25 +117,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,22 +155,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,22 +181,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +215,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -228,16 +223,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,13 +245,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -286,14 +276,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -306,7 +288,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,18 +306,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -348,7 +322,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -364,19 +338,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -409,7 +373,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -419,17 +383,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -444,12 +406,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,21 +424,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,11 +447,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -508,12 +464,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,21 +482,20 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,13 +507,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -592,7 +542,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -603,7 +552,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -625,11 +574,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -640,7 +588,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -660,17 +608,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -693,7 +638,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -701,16 +646,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -722,20 +666,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] @@ -747,7 +686,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,15 +697,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -777,14 +715,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -794,11 +732,11 @@ async def extract_data(pipeline_response): 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 @@ -810,8 +748,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -822,7 +758,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] @@ -834,7 +769,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,16 +780,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -865,14 +799,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -882,11 +816,11 @@ async def extract_data(pipeline_response): 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 @@ -898,10 +832,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -915,12 +845,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -934,21 +863,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -960,13 +888,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -994,7 +918,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1005,7 +928,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1021,11 +944,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1036,7 +958,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1049,18 +971,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1083,7 +1001,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1091,16 +1009,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1112,13 +1029,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1145,7 +1058,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1156,7 +1068,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1172,11 +1084,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1187,7 +1098,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1200,17 +1111,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1233,7 +1140,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1241,16 +1148,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,13 +1168,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1294,7 +1196,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1305,7 +1206,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1320,11 +1221,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1335,7 +1235,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1348,17 +1248,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1381,7 +1277,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1389,16 +1285,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1410,10 +1305,6 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py index f486af61d4a1..c8829cd2187a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usage_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py index fc7e96cf3511..1439256ff1e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py @@ -20,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -165,7 +165,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -201,7 +201,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2016_12_01.models.EncryptionServices @@ -454,7 +454,7 @@ def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, s class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -623,7 +623,7 @@ class Sku(_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 name: Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Required. Known values are: @@ -797,10 +797,10 @@ def __init__( self.enable_https_traffic_only = enable_https_traffic_only -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. - 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 name: Required. :vartype name: str @@ -837,7 +837,7 @@ def __init__( class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku @@ -1023,7 +1023,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: Required. :vartype key_name: str diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py index e485a07c75b1..981fccbf45ca 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -433,7 +438,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -441,18 +445,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -460,25 +463,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,22 +501,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,22 +527,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +561,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -574,16 +569,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -597,13 +591,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -632,14 +622,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] @@ -651,7 +633,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -669,18 +651,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] @@ -692,7 +666,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -708,19 +682,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] @@ -752,7 +716,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -762,17 +726,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -787,12 +749,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -806,21 +767,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -830,11 +790,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -849,12 +805,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,21 +823,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -894,13 +848,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -933,7 +883,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -944,7 +893,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -966,11 +915,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -981,7 +929,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1001,17 +949,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1034,7 +979,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1042,16 +987,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1063,20 +1007,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1087,7 +1026,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1098,15 +1037,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1117,14 +1055,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1134,11 +1072,11 @@ def extract_data(pipeline_response): 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 @@ -1150,8 +1088,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1160,7 +1096,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1171,7 +1106,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1182,16 +1117,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1202,14 +1136,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1219,11 +1153,11 @@ def extract_data(pipeline_response): 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 @@ -1235,10 +1169,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1252,12 +1182,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1271,21 +1200,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1297,13 +1225,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1331,7 +1255,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1342,7 +1265,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1358,11 +1281,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1373,7 +1295,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1386,18 +1308,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1420,7 +1338,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1428,16 +1346,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,13 +1366,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1482,7 +1395,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1493,7 +1405,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1509,11 +1421,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1524,7 +1435,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1537,17 +1448,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1570,7 +1477,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1578,16 +1485,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1599,13 +1505,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1631,7 +1533,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1642,7 +1543,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1657,11 +1558,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1672,7 +1572,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1685,17 +1585,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1718,7 +1614,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1726,16 +1622,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1747,10 +1642,6 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py index dacf7a70355d..1763e0c4bb26 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-12-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py index eaecd8a04c22..e27394844bfd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2017-06-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json index 0c8b7dce3986..b4b43b89dad4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py index e0bf5404bcde..8e0af196437c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -55,7 +57,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -68,7 +88,7 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-06-01") - 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 @@ -88,7 +108,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py index 1ceab72ac49e..fa18f5c958e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2017-06-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py index f6796dcbee6e..1b663a575503 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -56,7 +58,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -69,7 +89,9 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-06-01") - 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 @@ -89,7 +111,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py index ac09d6617138..55a8c1dc6300 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py index 23e88121666a..e54fbd1ab774 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py index cc6ab50f305e..8b2603496358 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -87,7 +92,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +99,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -114,25 +117,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,22 +155,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,22 +181,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +215,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -228,16 +223,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,13 +245,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -286,14 +276,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -306,7 +288,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,18 +306,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -348,7 +322,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -364,19 +338,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -409,7 +373,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -419,17 +383,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -444,12 +406,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,21 +424,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,11 +447,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -508,12 +464,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,21 +482,20 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,13 +507,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -592,7 +542,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -603,7 +552,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -625,11 +574,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -640,7 +588,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -660,17 +608,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -693,7 +638,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -701,16 +646,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -722,20 +666,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] @@ -747,7 +686,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,15 +697,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -777,14 +715,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -794,11 +732,11 @@ async def extract_data(pipeline_response): 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 @@ -810,8 +748,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -822,7 +758,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] @@ -834,7 +769,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,16 +780,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -865,14 +799,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -882,11 +816,11 @@ async def extract_data(pipeline_response): 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 @@ -898,10 +832,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -915,12 +845,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -934,21 +863,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -960,13 +888,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -994,7 +918,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1005,7 +928,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1021,11 +944,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1036,7 +958,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1049,18 +971,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1083,7 +1001,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1091,16 +1009,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1112,13 +1029,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1145,7 +1058,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1156,7 +1068,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1172,11 +1084,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1187,7 +1098,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1200,17 +1111,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1233,7 +1140,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1241,16 +1148,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,13 +1168,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1294,7 +1196,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1305,7 +1206,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1320,11 +1221,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1335,7 +1235,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1348,17 +1248,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1381,7 +1277,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1389,16 +1285,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1410,10 +1305,6 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py index 79eb4ce2e9e3..ee0c5ccba978 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usage_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py index 799000acab51..e012bfb9bd9b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -165,7 +159,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -227,7 +221,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2017_06_01.models.EncryptionServices @@ -397,7 +391,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -431,7 +425,7 @@ def __init__(self, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -631,7 +625,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -888,7 +882,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -1081,7 +1075,7 @@ class Sku(_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 name: Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Required. Known values are: @@ -1334,12 +1328,12 @@ def __init__( self.network_rule_set = None -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -1372,7 +1366,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku @@ -1572,7 +1566,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2. Required. @@ -1801,10 +1795,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -1834,7 +1828,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py index e11dd5cae5cf..bcb68adbb087 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py index f8aca129845d..b1ded8632765 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py index a0834f85d9b3..e7abb7a05e80 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -433,7 +438,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -441,18 +445,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -460,25 +463,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,22 +501,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,22 +527,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +561,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -574,16 +569,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -597,13 +591,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -632,14 +622,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] @@ -651,7 +633,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -669,18 +651,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] @@ -692,7 +666,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -708,19 +682,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] @@ -752,7 +716,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -762,17 +726,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -787,12 +749,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -806,21 +767,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -830,11 +790,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -849,12 +805,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,21 +823,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -894,13 +848,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -933,7 +883,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -944,7 +893,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -966,11 +915,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -981,7 +929,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1001,17 +949,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1034,7 +979,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1042,16 +987,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1063,20 +1007,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1087,7 +1026,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1098,15 +1037,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1117,14 +1055,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1134,11 +1072,11 @@ def extract_data(pipeline_response): 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 @@ -1150,8 +1088,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1160,7 +1096,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1171,7 +1106,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1182,16 +1117,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1202,14 +1136,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1219,11 +1153,11 @@ def extract_data(pipeline_response): 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 @@ -1235,10 +1169,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1252,12 +1182,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1271,21 +1200,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1297,13 +1225,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1331,7 +1255,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1342,7 +1265,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1358,11 +1281,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1373,7 +1295,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1386,18 +1308,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1420,7 +1338,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1428,16 +1346,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,13 +1366,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1482,7 +1395,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1493,7 +1405,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1509,11 +1421,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1524,7 +1435,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1537,17 +1448,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1570,7 +1477,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1578,16 +1485,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1599,13 +1505,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1631,7 +1533,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1642,7 +1543,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1657,11 +1558,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1672,7 +1572,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1685,17 +1585,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1718,7 +1614,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1726,16 +1622,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1747,10 +1642,6 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py index 24e36705c096..0a42f4cc9a4c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-06-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py index 4765a9623909..e9160a98d485 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2017-10-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json index ccc759489e16..3483d607603e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py index 6e1e90d888c0..e70c762bb6b8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -55,7 +57,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -68,7 +88,7 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-10-01") - 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 @@ -88,7 +108,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py index 8038b9ad2338..78a95de1e473 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/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 StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2017-10-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py index c84217f81ba7..726cc155f1c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -56,7 +58,25 @@ def __init__( **kwargs: Any ) -> None: self._config = StorageManagementConfiguration(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) @@ -69,7 +89,9 @@ def __init__( ) self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-10-01") - 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 @@ -89,7 +111,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py index b7b7bbde1393..a5aaccc7964c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py index ebedfdc940d4..25f1d84fc141 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py index 6421a0750d09..4a6de0c283b6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -87,7 +92,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +99,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -114,25 +117,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,22 +155,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,22 +181,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +215,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -228,16 +223,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,13 +245,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -286,14 +276,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -306,7 +288,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,18 +306,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -348,7 +322,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -364,19 +338,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -409,7 +373,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -419,17 +383,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -444,12 +406,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,21 +424,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,11 +447,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -508,12 +464,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,21 +482,20 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,13 +507,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -592,7 +542,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -603,7 +552,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -625,11 +574,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -640,7 +588,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -660,17 +608,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -693,7 +638,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -701,16 +646,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -722,20 +666,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] @@ -747,7 +686,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,15 +697,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -777,14 +715,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -794,11 +732,11 @@ async def extract_data(pipeline_response): 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 @@ -810,8 +748,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -822,7 +758,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] @@ -834,7 +769,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,16 +780,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -865,14 +799,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -882,11 +816,11 @@ async def extract_data(pipeline_response): 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 @@ -898,10 +832,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -915,12 +845,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -934,21 +863,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -960,13 +888,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -994,7 +918,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1005,7 +928,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1021,11 +944,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1036,7 +958,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1049,18 +971,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1083,7 +1001,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1091,16 +1009,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1112,13 +1029,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1145,7 +1058,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1156,7 +1068,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1172,11 +1084,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1187,7 +1098,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1200,17 +1111,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1233,7 +1140,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1241,16 +1148,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,13 +1168,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1294,7 +1196,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1305,7 +1206,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1320,11 +1221,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1335,7 +1235,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1348,17 +1248,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1381,7 +1277,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1389,16 +1285,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1410,10 +1305,6 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py index 62f69076dc2b..82f0b03597f3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usage_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py index ff4e9c2aece1..d4f6532dd4e7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -165,7 +159,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -227,7 +221,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2017_10_01.models.EncryptionServices @@ -397,7 +391,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -431,7 +425,7 @@ def __init__(self, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -631,7 +625,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -888,7 +882,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -1081,7 +1075,7 @@ class Sku(_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 name: Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Required. Known values are: @@ -1334,12 +1328,12 @@ def __init__( self.network_rule_set = None -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -1372,7 +1366,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku @@ -1572,7 +1566,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2. Required. @@ -1810,10 +1804,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -1843,7 +1837,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py index a30422246698..f083729b23e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py index 30cfb38731c6..230c0823c1af 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py index ae8bca560a6c..d6d0140c364c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -433,7 +438,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -441,18 +445,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -460,25 +463,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,22 +501,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,22 +527,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +561,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -574,16 +569,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -597,13 +591,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -632,14 +622,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] @@ -651,7 +633,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -669,18 +651,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] @@ -692,7 +666,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -708,19 +682,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] @@ -752,7 +716,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -762,17 +726,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -787,12 +749,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -806,21 +767,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -830,11 +790,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -849,12 +805,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,21 +823,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -894,13 +848,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -933,7 +883,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -944,7 +893,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -966,11 +915,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -981,7 +929,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1001,17 +949,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1034,7 +979,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1042,16 +987,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1063,20 +1007,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1087,7 +1026,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1098,15 +1037,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1117,14 +1055,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1134,11 +1072,11 @@ def extract_data(pipeline_response): 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 @@ -1150,8 +1088,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1160,7 +1096,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1171,7 +1106,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1182,16 +1117,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1202,14 +1136,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1219,11 +1153,11 @@ def extract_data(pipeline_response): 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 @@ -1235,10 +1169,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1252,12 +1182,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1271,21 +1200,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1297,13 +1225,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1331,7 +1255,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1342,7 +1265,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1358,11 +1281,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1373,7 +1295,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1386,18 +1308,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1420,7 +1338,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1428,16 +1346,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,13 +1366,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1482,7 +1395,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1493,7 +1405,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1509,11 +1421,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1524,7 +1435,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1537,17 +1448,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1570,7 +1477,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1578,16 +1485,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1599,13 +1505,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1631,7 +1533,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1642,7 +1543,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1657,11 +1558,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1672,7 +1572,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1685,17 +1585,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1718,7 +1614,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1726,16 +1622,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1747,10 +1642,6 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py index 29fd31704d17..f2445500601c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py index 12511e179bb8..a32884e28a53 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-02-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json index ecd761e61bfa..0b1ed2583e14 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py index c341049bb40d..012416d187fa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -58,7 +60,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -74,7 +94,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-02-01" ) - 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 @@ -94,7 +114,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py index aead9cf0c2f7..ca6b0160974a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-02-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py index 42af4d1b0746..e68f0596f59f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -60,7 +62,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -76,7 +96,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-02-01" ) - 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 @@ -96,7 +118,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py index 5e6e338e6fde..4c288996f15d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,6 +43,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]] @@ -78,12 +83,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,21 +101,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload async def create( @@ -163,7 +162,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -175,7 +173,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -197,11 +195,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -213,7 +210,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -233,17 +230,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,7 +259,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -275,16 +268,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,13 +288,9 @@ async def create( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @overload async def update( @@ -335,7 +323,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -347,7 +334,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -368,11 +355,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -384,7 +370,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -403,17 +389,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +418,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -445,16 +427,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -466,13 +447,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -492,12 +469,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,22 +487,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,13 +513,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -564,12 +535,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,22 +553,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,11 +577,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -646,7 +611,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -658,7 +622,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -680,11 +644,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -696,7 +659,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -716,17 +679,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -749,7 +708,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -758,16 +717,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -779,13 +737,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -818,7 +772,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -830,7 +783,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -851,11 +804,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -867,7 +819,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -886,17 +838,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -919,7 +867,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -928,16 +876,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -949,13 +896,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -998,7 +941,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1012,7 +954,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1041,11 +983,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1059,7 +1000,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1085,17 +1026,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1121,7 +1058,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1132,16 +1069,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1156,13 +1092,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1196,12 +1128,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1215,7 +1146,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1223,16 +1154,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1247,13 +1177,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1289,12 +1215,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1308,7 +1233,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1316,16 +1241,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1340,13 +1264,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1371,12 +1291,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1390,23 +1309,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1421,13 +1339,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1467,7 +1381,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1480,7 +1393,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1507,11 +1420,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1524,7 +1436,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1548,17 +1460,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1584,7 +1492,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1594,16 +1502,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1618,13 +1525,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1657,7 +1560,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1669,7 +1571,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1690,11 +1592,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1706,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1724,18 +1625,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1761,7 +1658,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1770,16 +1667,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1791,10 +1687,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py index a8f206b0e1a4..4b9f60bd2d31 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py index 85095998f236..f3a499e5ee7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py index 572b2cf34e6a..4374c44dffd1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -87,7 +92,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +99,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -114,25 +117,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,22 +155,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,22 +181,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +215,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -228,16 +223,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,13 +245,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -286,14 +276,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -306,7 +288,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,18 +306,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -348,7 +322,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -364,19 +338,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -409,7 +373,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -419,17 +383,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -444,12 +406,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,21 +424,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -487,11 +447,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -508,12 +464,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,21 +482,20 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,13 +507,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -592,7 +542,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -603,7 +552,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -625,11 +574,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -640,7 +588,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -660,17 +608,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -693,7 +638,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -701,16 +646,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -722,20 +666,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] @@ -747,7 +686,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,15 +697,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -777,14 +715,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -794,11 +732,11 @@ async def extract_data(pipeline_response): 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 @@ -810,8 +748,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -822,7 +758,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] @@ -834,7 +769,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,16 +780,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -865,14 +799,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -882,11 +816,11 @@ async def extract_data(pipeline_response): 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 @@ -898,10 +832,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -915,12 +845,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -934,21 +863,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -960,13 +888,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -994,7 +918,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1005,7 +928,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1021,11 +944,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1036,7 +958,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1049,18 +971,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1083,7 +1001,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1091,16 +1009,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1112,13 +1029,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1145,7 +1058,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1156,7 +1068,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1172,11 +1084,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1187,7 +1098,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1200,17 +1111,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1233,7 +1140,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1241,16 +1148,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,13 +1168,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1294,7 +1196,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1305,7 +1206,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1320,11 +1221,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1335,7 +1235,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1348,17 +1248,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1381,7 +1277,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1389,16 +1285,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1410,10 +1305,6 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py index 3a38fbfcd9eb..778f859d29d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usage_operations import build_list_by_location_request, 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -131,8 +134,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} - @distributed_trace def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the @@ -140,7 +141,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -151,7 +151,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,16 +162,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -182,14 +181,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -199,11 +198,11 @@ async def extract_data(pipeline_response): 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 @@ -214,7 +213,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py index 42bc3484663d..2ce6bcde5fb9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -131,7 +125,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. Ex - - /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 @@ -166,7 +160,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -203,7 +197,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -343,7 +337,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -405,7 +399,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_02_01.models.EncryptionServices @@ -586,7 +580,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -623,10 +617,10 @@ class ImmutabilityPolicy(AzureEntityResource): 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. Ex - - /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 @@ -724,7 +718,7 @@ def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -797,10 +791,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -839,7 +833,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -896,7 +890,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -991,7 +985,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1218,7 +1212,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -1434,7 +1428,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -1625,7 +1619,7 @@ class Sku(_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 name: Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Required. Known values are: @@ -1731,10 +1725,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. Ex - - /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 @@ -1779,10 +1773,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -1937,12 +1931,12 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -1975,7 +1969,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku @@ -2182,7 +2176,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2. Required. @@ -2514,10 +2508,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -2547,7 +2541,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py index 63b3d0d7b870..8ef62cd2100f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py @@ -106,7 +106,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py index a480951d7249..b4164e4d9bfd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -276,7 +281,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -564,12 +569,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,21 +587,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,13 +612,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload def create( @@ -649,7 +648,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +659,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -683,11 +681,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -699,7 +696,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -719,17 +716,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -752,7 +745,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -761,16 +754,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -782,13 +774,9 @@ def create( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @overload def update( @@ -821,7 +809,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -833,7 +820,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -854,11 +841,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -870,7 +856,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -889,17 +875,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -922,7 +904,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -931,16 +913,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -952,13 +933,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -978,12 +955,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,22 +973,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1024,13 +999,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1050,12 +1021,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,22 +1039,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1094,11 +1063,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1132,7 +1097,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1144,7 +1108,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1166,11 +1130,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1182,7 +1145,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1202,17 +1165,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1235,7 +1194,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1244,16 +1203,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1265,13 +1223,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1304,7 +1258,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1316,7 +1269,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1337,11 +1290,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1353,7 +1305,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1372,17 +1324,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1405,7 +1353,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1414,16 +1362,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,13 +1382,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1484,7 +1427,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1498,7 +1440,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1527,11 +1469,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1545,7 +1486,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1571,17 +1512,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1607,7 +1544,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1618,16 +1555,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1578,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1682,12 +1614,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1701,7 +1632,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1709,16 +1640,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1733,13 +1663,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1775,12 +1701,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1794,7 +1719,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1802,16 +1727,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1826,13 +1750,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1857,12 +1777,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1876,23 +1795,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1907,13 +1825,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -1953,7 +1867,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1966,7 +1879,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1993,11 +1906,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2010,7 +1922,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2034,17 +1946,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2070,7 +1978,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2080,16 +1988,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2104,13 +2011,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2143,7 +2046,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2155,7 +2057,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2176,11 +2078,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2192,7 +2093,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2210,18 +2111,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2247,7 +2144,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2256,16 +2153,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2277,10 +2173,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py index d82a6ba9a69a..2aaa9ffd0c59 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py index f75261d79500..5640f4fb58c0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py index 864112491648..8095a41ba83c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -433,7 +438,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -441,18 +445,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -460,25 +463,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,22 +501,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,22 +527,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +561,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -574,16 +569,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -597,13 +591,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -632,14 +622,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] @@ -651,7 +633,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -669,18 +651,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] @@ -692,7 +666,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -708,19 +682,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] @@ -752,7 +716,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -762,17 +726,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -787,12 +749,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -806,21 +767,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -830,11 +790,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -849,12 +805,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -868,21 +823,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -894,13 +848,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -933,7 +883,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -944,7 +893,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -966,11 +915,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -981,7 +929,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1001,17 +949,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1034,7 +979,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1042,16 +987,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1063,20 +1007,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1087,7 +1026,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1098,15 +1037,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1117,14 +1055,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1134,11 +1072,11 @@ def extract_data(pipeline_response): 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 @@ -1150,8 +1088,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1160,7 +1096,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1171,7 +1106,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1182,16 +1117,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1202,14 +1136,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1219,11 +1153,11 @@ def extract_data(pipeline_response): 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 @@ -1235,10 +1169,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1252,12 +1182,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1271,21 +1200,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1297,13 +1225,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1331,7 +1255,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1342,7 +1265,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1358,11 +1281,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1373,7 +1295,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1386,18 +1308,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1420,7 +1338,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1428,16 +1346,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,13 +1366,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1482,7 +1395,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1493,7 +1405,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1509,11 +1421,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1524,7 +1435,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1537,17 +1448,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1570,7 +1477,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1578,16 +1485,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1599,13 +1505,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1631,7 +1533,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1642,7 +1543,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1657,11 +1558,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1672,7 +1572,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1685,17 +1585,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1718,7 +1614,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1726,16 +1622,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1747,10 +1642,6 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py index 461493b34aec..ed94dc23643c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -111,7 +116,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -122,7 +126,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -133,15 +137,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -152,14 +155,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -169,11 +172,11 @@ def extract_data(pipeline_response): 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 @@ -185,8 +188,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} - @distributed_trace def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the @@ -194,7 +195,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -205,7 +205,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-02-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,16 +216,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -236,14 +235,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -253,11 +252,11 @@ def extract_data(pipeline_response): 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 @@ -268,7 +267,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py index 3c03a5300314..9c94ede524e1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-03-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json index 5a75f6c882fd..d82b92dd9c83 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py index eee400e71f83..98db49918487 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -70,7 +72,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -93,7 +113,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-03-01-preview" ) - 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 @@ -113,7 +133,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py index 1bd9ef55eb40..43c808293f5d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-03-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py index 4ccb004ea1ef..203d5689a2d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -70,7 +72,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -93,7 +113,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-03-01-preview" ) - 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,7 +135,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py index c3e5daf94132..d8ef78c498f3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,6 +43,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]] @@ -78,12 +83,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,21 +103,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) ) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,13 +128,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload async def create( @@ -165,7 +164,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -199,11 +197,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -215,7 +212,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -235,17 +232,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,7 +263,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -279,16 +272,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,13 +292,9 @@ async def create( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @overload async def update( @@ -339,7 +327,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -351,7 +338,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -372,11 +359,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -388,7 +374,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -407,17 +393,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,7 +424,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -451,16 +433,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -472,13 +453,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -498,12 +475,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -519,22 +495,21 @@ async def get( ) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -546,13 +521,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -572,12 +543,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -593,22 +563,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,11 +587,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -656,7 +621,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -668,7 +632,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -690,11 +654,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -706,7 +669,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -726,17 +689,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,7 +720,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -770,16 +729,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -791,13 +749,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -830,7 +784,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -842,7 +795,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -863,11 +816,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -879,7 +831,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -898,17 +850,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -933,7 +881,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -942,16 +890,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -963,13 +910,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1012,7 +955,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1026,7 +968,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1055,11 +997,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1073,7 +1014,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1099,17 +1040,14 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1137,7 +1075,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1148,16 +1086,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1172,13 +1109,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1212,12 +1145,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1233,7 +1165,7 @@ async def get_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1241,16 +1173,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1265,13 +1196,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1307,12 +1234,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1328,7 +1254,7 @@ async def delete_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1336,16 +1262,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1360,13 +1285,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1391,12 +1312,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1412,23 +1332,22 @@ async def lock_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1443,13 +1362,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1489,7 +1404,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1502,7 +1416,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1529,11 +1443,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1546,7 +1459,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1570,17 +1483,14 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1608,7 +1518,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1618,16 +1528,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1551,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1681,7 +1586,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1693,7 +1597,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1714,11 +1618,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1633,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1748,18 +1651,15 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest or + IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1787,7 +1687,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1796,16 +1696,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1817,10 +1716,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_management_policies_operations.py index 79780fed7845..e7ae883d9ff7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,22 +102,21 @@ async def get( ) cls: ClsType[_models.StorageAccountManagementPolicies] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,13 +128,9 @@ async def get( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -163,7 +162,6 @@ async def 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 :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -175,7 +173,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -194,11 +192,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. 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: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -210,7 +207,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. @@ -227,18 +224,14 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. Is either a - ManagementPoliciesRulesSetParameter type or a IO type. Required. + ManagementPoliciesRulesSetParameter type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter 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 + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter or IO[bytes] :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,7 +256,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -272,16 +265,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,22 +330,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,8 +354,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py index 60b2e86c5708..92a62bfb9fe1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Operation] @@ -71,7 +75,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +86,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -117,11 +120,11 @@ async def extract_data(pipeline_response): 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 @@ -132,5 +135,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py index b340847d3528..627727bca5db 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Sku] @@ -71,7 +75,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: ) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,15 +86,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -101,14 +104,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -118,11 +121,11 @@ async def extract_data(pipeline_response): 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 @@ -133,5 +136,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py index 3f57095b4704..206e5dcdd6ce 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -48,6 +49,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]] @@ -90,7 +95,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -98,18 +102,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -117,26 +120,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -188,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +222,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -236,16 +230,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,13 +252,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -294,14 +283,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -314,7 +295,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,18 +313,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -356,7 +329,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -372,20 +345,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. + StorageAccountCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCreateParameters - 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. + or IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -420,7 +382,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -430,17 +392,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -455,12 +415,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -476,21 +435,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -500,11 +458,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -521,12 +475,11 @@ async def get_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -542,21 +495,20 @@ async def get_properties( ) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,13 +520,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -607,7 +555,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -618,7 +565,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -640,11 +587,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -655,7 +601,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -675,18 +621,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. + StorageAccountUpdateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountUpdateParameters - 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 + or IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +653,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -719,16 +661,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,20 +681,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] @@ -767,7 +703,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,15 +714,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -797,14 +732,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -814,11 +749,11 @@ async def extract_data(pipeline_response): 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 @@ -830,8 +765,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -842,7 +775,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] @@ -856,7 +788,7 @@ def list_by_resource_group( ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -867,16 +799,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -887,14 +818,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -904,11 +835,11 @@ async def extract_data(pipeline_response): 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 @@ -920,10 +851,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -937,12 +864,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,21 +884,20 @@ async def list_keys( ) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -984,13 +909,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1018,7 +939,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1029,7 +949,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1045,11 +965,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1060,7 +979,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1073,18 +992,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters or + IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1109,7 +1025,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1117,16 +1033,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1138,13 +1053,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1171,7 +1082,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1182,7 +1092,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1198,11 +1108,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1213,7 +1122,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1226,17 +1135,14 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters or + IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1261,7 +1167,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1269,16 +1175,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1290,13 +1195,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1322,7 +1223,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1333,7 +1233,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1348,11 +1248,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1363,7 +1262,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1376,17 +1275,14 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters or + IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1411,7 +1307,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1419,16 +1315,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1440,13 +1335,9 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore @distributed_trace_async async def get_management_policies( @@ -1469,12 +1360,11 @@ async def get_management_policies( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1490,22 +1380,21 @@ async def get_management_policies( ) cls: ClsType[_models.StorageAccountManagementPolicies] = kwargs.pop("cls", None) - request = build_get_management_policies_request( + _request = build_get_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_management_policies.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1517,13 +1406,9 @@ async def get_management_policies( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_management_policies.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update_management_policies( @@ -1555,7 +1440,6 @@ async def create_or_update_management_policies( :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: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -1567,7 +1451,7 @@ async def create_or_update_management_policies( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1586,11 +1470,10 @@ async def create_or_update_management_policies( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. 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: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -1602,7 +1485,7 @@ async def create_or_update_management_policies( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. @@ -1619,18 +1502,14 @@ async def create_or_update_management_policies( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. Is either a - ManagementPoliciesRulesSetParameter type or a IO type. Required. + ManagementPoliciesRulesSetParameter type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter 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 + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter or IO[bytes] :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1655,7 +1534,7 @@ async def create_or_update_management_policies( else: _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") - request = build_create_or_update_management_policies_request( + _request = build_create_or_update_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -1664,16 +1543,15 @@ async def create_or_update_management_policies( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_management_policies.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1685,13 +1563,9 @@ async def create_or_update_management_policies( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_management_policies.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_management_policies( # pylint: disable=inconsistent-return-statements @@ -1714,12 +1588,11 @@ async def delete_management_policies( # pylint: disable=inconsistent-return-sta always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1735,22 +1608,21 @@ async def delete_management_policies( # pylint: disable=inconsistent-return-sta ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_management_policies_request( + _request = build_delete_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_management_policies.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1760,8 +1632,4 @@ async def delete_management_policies( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_management_policies.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py index e6e662ebbf7c..5caa94145772 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request, 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] @@ -71,7 +75,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: ) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,15 +86,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -101,14 +104,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -118,11 +121,11 @@ async def extract_data(pipeline_response): 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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} - @distributed_trace def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the @@ -143,7 +144,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] @@ -157,7 +157,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,16 +168,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -188,14 +187,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -205,11 +204,11 @@ async def extract_data(pipeline_response): 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 @@ -220,7 +219,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py index d593075be017..9ca85d76f85c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py @@ -9,7 +9,7 @@ import datetime import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -17,10 +17,6 @@ from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -31,7 +27,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -138,7 +134,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. Ex - - /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 @@ -173,7 +169,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -210,7 +206,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -350,7 +346,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -412,7 +408,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_03_01_preview.models.EncryptionServices @@ -595,7 +591,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -632,10 +628,10 @@ class ImmutabilityPolicy(AzureEntityResource): 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. Ex - - /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 @@ -734,7 +730,7 @@ def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -807,10 +803,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -850,7 +846,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -908,7 +904,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -1003,7 +999,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1276,7 +1272,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -1495,7 +1491,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -1686,7 +1682,7 @@ class Sku(_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 name: Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Required. Known values are: @@ -1792,10 +1788,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. Ex - - /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 @@ -1840,10 +1836,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -2000,12 +1996,12 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -2038,7 +2034,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku @@ -2248,7 +2244,7 @@ class StorageAccountManagementPolicies(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2288,7 +2284,7 @@ def __init__(self, *, policy: Optional[JSON] = None, **kwargs: Any) -> None: self.last_modified_time = None -class StorageAccountManagementPoliciesRulesProperty(ManagementPoliciesRules): +class StorageAccountManagementPoliciesRulesProperty(ManagementPoliciesRules): # pylint: disable=name-too-long """The Storage Account Data Policies properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2322,7 +2318,7 @@ def __init__(self, *, policy: Optional[JSON] = None, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2. Required. @@ -2655,10 +2651,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -2688,7 +2684,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py index 791d36adcf7e..67ac5d08d6fc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py @@ -106,7 +106,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py index 2ac9593a1ab9..ecff71203244 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -276,7 +281,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -564,12 +569,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,21 +589,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m ) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -611,13 +614,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload def create( @@ -651,7 +650,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -663,7 +661,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -685,11 +683,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -701,7 +698,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -721,17 +718,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -756,7 +749,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -765,16 +758,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -786,13 +778,9 @@ def create( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @overload def update( @@ -825,7 +813,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -837,7 +824,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -858,11 +845,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -874,7 +860,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -893,17 +879,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -928,7 +910,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -937,16 +919,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -958,13 +939,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -984,12 +961,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1005,22 +981,21 @@ def get( ) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1032,13 +1007,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1058,12 +1029,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1079,22 +1049,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1104,11 +1073,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1142,7 +1107,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1154,7 +1118,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1176,11 +1140,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1192,7 +1155,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1212,17 +1175,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1247,7 +1206,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1256,16 +1215,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1277,13 +1235,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1316,7 +1270,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1328,7 +1281,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1349,11 +1302,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1365,7 +1317,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1384,17 +1336,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1419,7 +1367,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1428,16 +1376,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,13 +1396,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1498,7 +1441,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1512,7 +1454,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1541,11 +1483,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1559,7 +1500,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1585,17 +1526,14 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1623,7 +1561,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1634,16 +1572,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1658,13 +1595,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1698,12 +1631,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1719,7 +1651,7 @@ def get_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1727,16 +1659,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1751,13 +1682,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1793,12 +1720,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1814,7 +1740,7 @@ def delete_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1822,16 +1748,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1846,13 +1771,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1877,12 +1798,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1898,23 +1818,22 @@ def lock_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1929,13 +1848,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -1975,7 +1890,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1988,7 +1902,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2015,11 +1929,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2032,7 +1945,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2056,17 +1969,14 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2094,7 +2004,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2104,16 +2014,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2128,13 +2037,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2167,7 +2072,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2179,7 +2083,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2200,11 +2104,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2216,7 +2119,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2234,18 +2137,15 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest or + IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2273,7 +2173,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2282,16 +2182,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2303,10 +2202,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_management_policies_operations.py index 183148f905bc..777ed8680d1b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,22 +212,21 @@ def get( ) cls: ClsType[_models.StorageAccountManagementPolicies] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,13 +238,9 @@ def get( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -273,7 +272,6 @@ def 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 :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -285,7 +283,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +302,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. 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: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +317,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. @@ -337,18 +334,14 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. Is either a - ManagementPoliciesRulesSetParameter type or a IO type. Required. + ManagementPoliciesRulesSetParameter type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter 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 + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter or IO[bytes] :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,7 +366,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -382,16 +375,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +395,9 @@ def create_or_update( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -432,12 +420,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -453,22 +440,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -478,8 +464,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py index 02634510b36b..d71ba6b97aca 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -92,7 +96,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,14 +107,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +124,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -138,11 +141,11 @@ def extract_data(pipeline_response): 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 @@ -153,5 +156,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py index 5460912517fb..787e21154230 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -97,7 +101,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: ) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,15 +112,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -127,14 +130,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -144,11 +147,11 @@ def extract_data(pipeline_response): 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 @@ -159,5 +162,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py index ee943d96ed69..29f8bbd371ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -433,7 +438,7 @@ def build_get_management_policies_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_management_policies_request( +def build_create_or_update_management_policies_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], @@ -544,7 +549,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -552,18 +556,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -571,26 +574,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -615,22 +614,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -642,22 +640,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -682,7 +676,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -690,16 +684,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -713,13 +706,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -748,14 +737,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -768,7 +749,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -786,18 +767,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -810,7 +783,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -826,20 +799,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. + StorageAccountCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCreateParameters - 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. + or IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -874,7 +836,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -884,17 +846,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -909,12 +869,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -930,21 +889,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -954,11 +912,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: @@ -973,12 +927,11 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -994,21 +947,20 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: ) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,13 +972,9 @@ def get_properties(self, resource_group_name: str, account_name: str, **kwargs: deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1059,7 +1007,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1070,7 +1017,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1092,11 +1039,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1107,7 +1053,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1127,18 +1073,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. + StorageAccountUpdateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountUpdateParameters - 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 + or IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1163,7 +1105,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1171,16 +1113,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1192,20 +1133,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] @@ -1219,7 +1155,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1230,15 +1166,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1249,14 +1184,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1266,11 +1201,11 @@ def extract_data(pipeline_response): 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 @@ -1282,8 +1217,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1292,7 +1225,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] @@ -1306,7 +1238,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1317,16 +1249,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1337,14 +1268,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1354,11 +1285,11 @@ def extract_data(pipeline_response): 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 @@ -1370,10 +1301,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1387,12 +1314,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1408,21 +1334,20 @@ def list_keys( ) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1434,13 +1359,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1468,7 +1389,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1479,7 +1399,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1495,11 +1415,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1510,7 +1429,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1523,18 +1442,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters or + IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1559,7 +1475,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1567,16 +1483,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1588,13 +1503,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1621,7 +1532,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1632,7 +1542,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1648,11 +1558,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1663,7 +1572,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1676,17 +1585,14 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters or + IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1711,7 +1617,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1719,16 +1625,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1740,13 +1645,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1772,7 +1673,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1783,7 +1683,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1798,11 +1698,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1813,7 +1712,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1826,17 +1725,14 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters or + IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1861,7 +1757,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1869,16 +1765,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1890,13 +1785,9 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore @distributed_trace def get_management_policies( @@ -1919,12 +1810,11 @@ def get_management_policies( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1940,22 +1830,21 @@ def get_management_policies( ) cls: ClsType[_models.StorageAccountManagementPolicies] = kwargs.pop("cls", None) - request = build_get_management_policies_request( + _request = build_get_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_management_policies.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1967,13 +1856,9 @@ def get_management_policies( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_management_policies.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update_management_policies( @@ -2005,7 +1890,6 @@ def create_or_update_management_policies( :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: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -2017,7 +1901,7 @@ def create_or_update_management_policies( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2036,11 +1920,10 @@ def create_or_update_management_policies( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. 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: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: @@ -2052,7 +1935,7 @@ def create_or_update_management_policies( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. @@ -2069,18 +1952,14 @@ def create_or_update_management_policies( :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. Is either a - ManagementPoliciesRulesSetParameter type or a IO type. Required. + ManagementPoliciesRulesSetParameter type or a IO[bytes] type. Required. :type properties: - ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter 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 + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter or IO[bytes] :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2105,7 +1984,7 @@ def create_or_update_management_policies( else: _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") - request = build_create_or_update_management_policies_request( + _request = build_create_or_update_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -2114,16 +1993,15 @@ def create_or_update_management_policies( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_management_policies.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2135,13 +2013,9 @@ def create_or_update_management_policies( deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_management_policies.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_management_policies( # pylint: disable=inconsistent-return-statements @@ -2164,12 +2038,11 @@ def delete_management_policies( # pylint: disable=inconsistent-return-statement always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2185,22 +2058,21 @@ def delete_management_policies( # pylint: disable=inconsistent-return-statement ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_management_policies_request( + _request = build_delete_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_management_policies.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2210,8 +2082,4 @@ def delete_management_policies( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_management_policies.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py index 60eb2b0fa61c..c8b444c05815 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -111,7 +116,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -124,7 +128,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: ) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -135,15 +139,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -154,14 +157,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -171,11 +174,11 @@ def extract_data(pipeline_response): 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 @@ -187,8 +190,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} - @distributed_trace def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the @@ -196,7 +197,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -209,7 +209,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us ) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,16 +220,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -240,14 +239,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -257,11 +256,11 @@ def extract_data(pipeline_response): 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 @@ -272,7 +271,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py index f3e49ffca22a..48876935caba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json index ad4ee5e9d48a..d557e44445ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py index f3223fae9ae3..aa238335366a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -67,7 +69,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -86,7 +106,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-07-01" ) - 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 @@ -106,7 +126,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py index 237b18e22fe9..9834f6fcca65 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-07-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py index f03a59489928..21b109512895 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -69,7 +71,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -88,7 +108,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-07-01" ) - 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 @@ -108,7 +130,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py index 866e20745b8f..5a367dbd3d97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,6 +43,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]] @@ -78,12 +83,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,21 +101,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload async def create( @@ -163,7 +162,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -175,7 +173,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -197,11 +195,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -213,7 +210,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -233,17 +230,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,7 +259,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -275,16 +268,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,13 +288,9 @@ async def create( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @overload async def update( @@ -335,7 +323,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -347,7 +334,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -368,11 +355,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -384,7 +370,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -403,17 +389,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +418,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -445,16 +427,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -466,13 +447,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -492,12 +469,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,22 +487,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,13 +513,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -564,12 +535,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,22 +553,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,11 +577,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -646,7 +611,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -658,7 +622,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -680,11 +644,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -696,7 +659,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -716,17 +679,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -749,7 +708,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -758,16 +717,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -779,13 +737,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -818,7 +772,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -830,7 +783,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -851,11 +804,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -867,7 +819,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -886,17 +838,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -919,7 +867,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -928,16 +876,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -949,13 +896,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -998,7 +941,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1012,7 +954,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1041,11 +983,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1059,7 +1000,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1085,17 +1026,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1121,7 +1058,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1132,16 +1069,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1156,13 +1092,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1196,12 +1128,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1215,7 +1146,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1223,16 +1154,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1247,13 +1177,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1289,12 +1215,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1308,7 +1233,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1316,16 +1241,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1340,13 +1264,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1371,12 +1291,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1390,23 +1309,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1421,13 +1339,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1467,7 +1381,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1480,7 +1393,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1507,11 +1420,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1524,7 +1436,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1548,17 +1460,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1584,7 +1492,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1594,16 +1502,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1618,13 +1525,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1657,7 +1560,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1669,7 +1571,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1690,11 +1592,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1706,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1724,18 +1625,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1761,7 +1658,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1770,16 +1667,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1791,10 +1687,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py index f121a473c943..18698bdd55ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ build_set_service_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]] @@ -85,7 +90,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -97,7 +101,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum8], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,11 +121,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -133,7 +136,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum8], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -151,17 +154,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -184,7 +183,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -193,16 +192,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -214,13 +212,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -239,12 +233,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,22 +251,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,10 +277,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py index 124ab602261e..5f4934670d7c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py index 093eeffa3f43..1ab41a9c5ad3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py index cf159cccf332..6ffafa121ada 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -47,10 +47,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -93,7 +93,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -101,18 +100,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -120,25 +118,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,22 +156,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -188,22 +182,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,7 +216,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -234,16 +224,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,13 +246,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -292,14 +277,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -312,7 +289,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -330,18 +307,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -354,7 +323,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -370,19 +339,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -415,7 +374,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -425,17 +384,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -450,12 +407,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,21 +425,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -493,11 +448,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -522,12 +473,11 @@ async def get_properties( data is not included when fetching properties. Currently we only support geoReplicationStats. Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,22 +491,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,13 +517,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -607,7 +552,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -618,7 +562,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -640,11 +584,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -655,7 +598,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -675,17 +618,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -708,7 +648,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -716,16 +656,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -737,20 +676,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] @@ -762,7 +696,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -773,15 +707,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -792,14 +725,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -809,11 +742,11 @@ async def extract_data(pipeline_response): 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 @@ -825,8 +758,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -837,7 +768,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] @@ -849,7 +779,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -860,16 +790,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -880,14 +809,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -897,11 +826,11 @@ async def extract_data(pipeline_response): 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 @@ -913,10 +842,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -930,12 +855,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -949,21 +873,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -975,13 +898,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1009,7 +928,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1020,7 +938,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1036,11 +954,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1051,7 +968,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1064,18 +981,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1098,7 +1011,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1106,16 +1019,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1127,13 +1039,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1160,7 +1068,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1171,7 +1078,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1187,11 +1094,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1202,7 +1108,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1215,17 +1121,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1248,7 +1150,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1256,16 +1158,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1277,13 +1178,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1309,7 +1206,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1320,7 +1216,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1335,11 +1231,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1350,7 +1245,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1363,17 +1258,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1396,7 +1287,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1404,16 +1295,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1425,18 +1315,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1450,21 +1336,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1474,11 +1359,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1493,14 +1374,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1527,7 +1400,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1538,14 +1411,10 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py index fb3264573a8e..eace551a20fc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py index fabf2cac0046..6839e4d3ee54 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -131,7 +125,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. Ex - - /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 @@ -166,7 +160,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -203,7 +197,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -309,7 +303,7 @@ class BlobServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -410,7 +404,7 @@ def __init__(self, **kwargs: Any) -> None: class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -507,7 +501,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -601,7 +595,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_07_01.models.EncryptionServices @@ -824,7 +818,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -861,10 +855,10 @@ class ImmutabilityPolicy(AzureEntityResource): 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. Ex - - /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 @@ -962,7 +956,7 @@ def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -1035,10 +1029,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1077,7 +1071,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1134,7 +1128,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -1229,7 +1223,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1456,7 +1450,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -1672,7 +1666,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -1863,7 +1857,7 @@ class Sku(_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 name: Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: @@ -1971,10 +1965,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. Ex - - /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 @@ -2019,10 +2013,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -2198,12 +2192,12 @@ def __init__( # pylint: disable=too-many-locals self.failover_in_progress = None -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -2236,7 +2230,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku @@ -2452,7 +2446,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2. Required. @@ -2796,10 +2790,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -2829,7 +2823,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py index f7aef6752b0d..a4e8084d989b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py @@ -133,7 +133,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py index e9da39fd19dd..a3435967bdf7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -276,7 +281,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -564,12 +569,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,21 +587,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,13 +612,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload def create( @@ -649,7 +648,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +659,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -683,11 +681,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -699,7 +696,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -719,17 +716,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -752,7 +745,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -761,16 +754,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -782,13 +774,9 @@ def create( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @overload def update( @@ -821,7 +809,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -833,7 +820,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -854,11 +841,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -870,7 +856,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -889,17 +875,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -922,7 +904,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -931,16 +913,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -952,13 +933,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -978,12 +955,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,22 +973,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1024,13 +999,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1050,12 +1021,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,22 +1039,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1094,11 +1063,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1132,7 +1097,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1144,7 +1108,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1166,11 +1130,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1182,7 +1145,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1202,17 +1165,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1235,7 +1194,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1244,16 +1203,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1265,13 +1223,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1304,7 +1258,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1316,7 +1269,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1337,11 +1290,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1353,7 +1305,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1372,17 +1324,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1405,7 +1353,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1414,16 +1362,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,13 +1382,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1484,7 +1427,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1498,7 +1440,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1527,11 +1469,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1545,7 +1486,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1571,17 +1512,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1607,7 +1544,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1618,16 +1555,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1578,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1682,12 +1614,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1701,7 +1632,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1709,16 +1640,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1733,13 +1663,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1775,12 +1701,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1794,7 +1719,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1802,16 +1727,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1826,13 +1750,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1857,12 +1777,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1876,23 +1795,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1907,13 +1825,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -1953,7 +1867,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1966,7 +1879,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1993,11 +1906,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2010,7 +1922,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2034,17 +1946,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2070,7 +1978,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2080,16 +1988,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2104,13 +2011,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2143,7 +2046,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2155,7 +2057,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2176,11 +2078,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2192,7 +2093,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2210,18 +2111,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2247,7 +2144,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2256,16 +2153,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2277,10 +2173,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py index 7be91c01c95b..3604440e00b4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -164,7 +169,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +180,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum8], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +200,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +215,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum8], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -230,17 +233,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,7 +262,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -272,16 +271,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +291,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -318,12 +312,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,22 +330,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,10 +356,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py index e1001080b1cc..02ad24fd85b4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py index ec5ddac25b1b..6afe4f9536eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py index 7e113cc3074e..f7d741a6c517 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -472,7 +472,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -480,18 +479,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -499,25 +497,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -540,22 +535,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -567,22 +561,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,7 +595,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -613,16 +603,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -636,13 +625,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -671,14 +656,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] @@ -690,7 +667,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -708,18 +685,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] @@ -731,7 +700,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -747,19 +716,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] @@ -791,7 +750,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -801,17 +760,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -826,12 +783,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -845,21 +801,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -869,11 +824,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -898,12 +849,11 @@ def get_properties( data is not included when fetching properties. Currently we only support geoReplicationStats. Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -917,22 +867,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -944,13 +893,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -983,7 +928,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -994,7 +938,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1016,11 +960,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1031,7 +974,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1051,17 +994,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1084,7 +1024,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1092,16 +1032,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1113,20 +1052,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1137,7 +1071,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1148,15 +1082,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1167,14 +1100,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1184,11 +1117,11 @@ def extract_data(pipeline_response): 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 @@ -1200,8 +1133,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1210,7 +1141,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1221,7 +1151,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1232,16 +1162,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1252,14 +1181,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1269,11 +1198,11 @@ def extract_data(pipeline_response): 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 @@ -1285,10 +1214,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1302,12 +1227,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1321,21 +1245,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1347,13 +1270,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1381,7 +1300,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1392,7 +1310,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1408,11 +1326,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1423,7 +1340,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1436,18 +1353,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1470,7 +1383,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1478,16 +1391,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1499,13 +1411,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1532,7 +1440,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1543,7 +1450,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1559,11 +1466,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1574,7 +1480,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1587,17 +1493,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1620,7 +1522,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1628,16 +1530,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1649,13 +1550,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1681,7 +1578,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1692,7 +1588,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1707,11 +1603,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1722,7 +1617,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1735,17 +1630,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1768,7 +1659,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1776,16 +1667,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1797,18 +1687,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,21 +1708,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1846,11 +1731,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1865,14 +1746,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1899,7 +1772,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1910,14 +1783,10 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py index 531e444a4406..2ec2533c4e11 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-07-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py index 9779c57ecf1a..784c1f2f9aa6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-11-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json index 5d4e624471c1..6a389ac15da5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py index e5805936c862..5e2e948134ab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -71,7 +73,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -93,7 +113,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-11-01" ) - 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 @@ -113,7 +133,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py index 859560ea723c..6bd238cf58cb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-11-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py index d5e6ed249479..ae9f4b66e9fc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -73,7 +75,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -95,7 +115,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-11-01" ) - 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 @@ -115,7 +137,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py index c88570f99648..aa39908d0905 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,6 +43,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]] @@ -78,12 +83,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,21 +101,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload async def create( @@ -163,7 +162,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -175,7 +173,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -197,11 +195,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -213,7 +210,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -233,17 +230,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,7 +259,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -275,16 +268,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -304,10 +296,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -339,7 +327,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -351,7 +338,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -372,11 +359,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -388,7 +374,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -407,17 +393,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +422,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -449,16 +431,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,13 +451,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -496,12 +473,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,22 +491,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -542,13 +517,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -568,12 +539,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -587,22 +557,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -612,11 +581,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -650,7 +615,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -662,7 +626,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -684,11 +648,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -700,7 +663,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -720,17 +683,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -753,7 +712,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -762,16 +721,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -783,13 +741,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -822,7 +776,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -834,7 +787,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -855,11 +808,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -871,7 +823,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -890,17 +842,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -923,7 +871,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -932,16 +880,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -953,13 +900,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1002,7 +945,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1016,7 +958,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1045,11 +987,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1063,7 +1004,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1089,17 +1030,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1125,7 +1062,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1136,16 +1073,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1160,13 +1096,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1200,12 +1132,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1219,7 +1150,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1227,16 +1158,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,13 +1181,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1293,12 +1219,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1312,7 +1237,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1320,16 +1245,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1344,13 +1268,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1375,12 +1295,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1394,23 +1313,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1425,13 +1343,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1471,7 +1385,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1484,7 +1397,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1511,11 +1424,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1528,7 +1440,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1552,17 +1464,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1588,7 +1496,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1598,16 +1506,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1622,13 +1529,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1661,7 +1564,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1673,7 +1575,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1694,11 +1596,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1710,7 +1611,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1728,18 +1629,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1765,7 +1662,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1774,16 +1671,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1795,10 +1691,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py index 88f8f5ea46fd..b9af8078f408 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ build_set_service_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]] @@ -85,7 +90,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -97,7 +101,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum10], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,11 +121,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -133,7 +136,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum10], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -151,17 +154,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -184,7 +183,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -193,16 +192,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -214,13 +212,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -239,12 +233,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,22 +251,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,10 +277,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py index 3a93c9205f0a..e3d3677624de 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py index 83f58c19444c..593395db3ba5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py index 06bdf30182cf..8dedcbb34162 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py index 7c1b5610e13e..3fce40606370 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -48,10 +48,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +94,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -102,18 +101,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -121,25 +119,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,22 +157,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -189,22 +183,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,7 +217,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -235,16 +225,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,13 +247,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -293,14 +278,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -313,7 +290,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -331,18 +308,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -355,7 +324,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -371,19 +340,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -416,7 +375,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -426,17 +385,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -451,12 +408,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,21 +426,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,11 +449,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -523,12 +474,11 @@ async def get_properties( data is not included when fetching properties. Currently we only support geoReplicationStats. Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -542,22 +492,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,13 +518,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -608,7 +553,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -619,7 +563,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -641,11 +585,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -656,7 +599,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -676,17 +619,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -709,7 +649,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -717,16 +657,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,20 +677,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] @@ -763,7 +697,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -774,15 +708,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -793,14 +726,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -810,11 +743,11 @@ async def extract_data(pipeline_response): 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 @@ -826,8 +759,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -838,7 +769,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] @@ -850,7 +780,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -861,16 +791,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -881,14 +810,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -898,11 +827,11 @@ async def extract_data(pipeline_response): 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 @@ -914,10 +843,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -931,12 +856,11 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -950,21 +874,20 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -976,13 +899,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1010,7 +929,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1021,7 +939,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1037,11 +955,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1052,7 +969,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1065,18 +982,14 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1099,7 +1012,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1107,16 +1020,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1128,13 +1040,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1161,7 +1069,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1172,7 +1079,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1188,11 +1095,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1203,7 +1109,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1216,17 +1122,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1249,7 +1151,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1257,16 +1159,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1278,13 +1179,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1310,7 +1207,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1321,7 +1217,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1336,11 +1232,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1351,7 +1246,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1364,17 +1259,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1397,7 +1288,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1405,16 +1296,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1426,18 +1316,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,21 +1337,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1475,11 +1360,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1494,14 +1375,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1528,7 +1401,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1539,17 +1412,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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1564,12 +1433,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1583,21 +1451,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1607,8 +1474,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py index 37d4254f4831..3c033e6eb509 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py index 0c5e8811d1b4..82eae1af04b6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -131,7 +125,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. Ex - - /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 @@ -166,7 +160,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -203,7 +197,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -309,7 +303,7 @@ class BlobServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -410,7 +404,7 @@ def __init__(self, **kwargs: Any) -> None: class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -507,7 +501,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -543,7 +537,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Integer value indicating the age in days after creation. Required. @@ -571,7 +565,7 @@ def __init__(self, *, days_after_creation_greater_than: int, **kwargs: Any) -> N class DateAfterModification(_serialization.Model): """Object to define the number of days after last modification. - 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 days_after_modification_greater_than: Integer value indicating the age in days after last modification. Required. @@ -657,7 +651,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_11_01.models.EncryptionServices @@ -880,7 +874,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -917,10 +911,10 @@ class ImmutabilityPolicy(AzureEntityResource): 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. Ex - - /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 @@ -1018,7 +1012,7 @@ def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -1091,10 +1085,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1133,7 +1127,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1190,7 +1184,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -1285,7 +1279,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1434,7 +1428,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1553,7 +1547,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyAction @@ -1592,7 +1586,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -1624,7 +1618,7 @@ def __init__(self, *, blob_types: List[str], prefix_match: Optional[List[str]] = class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -1681,7 +1675,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -1812,7 +1806,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -2028,7 +2022,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -2219,7 +2213,7 @@ class Sku(_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 name: Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: @@ -2327,10 +2321,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. Ex - - /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 @@ -2375,10 +2369,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -2554,12 +2548,12 @@ def __init__( # pylint: disable=too-many-locals self.failover_in_progress = None -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -2592,7 +2586,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku @@ -2808,7 +2802,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2. Required. @@ -3152,10 +3146,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -3185,7 +3179,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py index 355726683af8..a1076c70bcec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py @@ -133,7 +133,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py index 29504bd3a7aa..3de7fa1159e8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -276,7 +281,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -564,12 +569,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListContainerItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,21 +587,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,13 +612,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } + return deserialized # type: ignore @overload def create( @@ -649,7 +648,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +659,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -683,11 +681,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -699,7 +696,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -719,17 +716,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -752,7 +745,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -761,16 +754,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -790,10 +782,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -825,7 +813,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -837,7 +824,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -858,11 +845,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -874,7 +860,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -893,17 +879,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -926,7 +908,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -935,16 +917,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -956,13 +937,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -982,12 +959,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1001,22 +977,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1028,13 +1003,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1054,12 +1025,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1073,22 +1043,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1098,11 +1067,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1136,7 +1101,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1148,7 +1112,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1170,11 +1134,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1186,7 +1149,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1206,17 +1169,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1239,7 +1198,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1248,16 +1207,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1269,13 +1227,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1308,7 +1262,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1320,7 +1273,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1341,11 +1294,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1357,7 +1309,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1376,17 +1328,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1409,7 +1357,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1418,16 +1366,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1439,13 +1386,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1488,7 +1431,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1502,7 +1444,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1531,11 +1473,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1549,7 +1490,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1575,17 +1516,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1611,7 +1548,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1622,16 +1559,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1646,13 +1582,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1686,12 +1618,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1705,7 +1636,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1713,16 +1644,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1737,13 +1667,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1779,12 +1705,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1798,7 +1723,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1806,16 +1731,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1830,13 +1754,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1861,12 +1781,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1880,23 +1799,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1911,13 +1829,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -1957,7 +1871,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1970,7 +1883,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1997,11 +1910,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2014,7 +1926,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2038,17 +1950,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2074,7 +1982,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2084,16 +1992,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2108,13 +2015,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2147,7 +2050,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2159,7 +2061,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2180,11 +2082,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2196,7 +2097,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2214,18 +2115,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2251,7 +2148,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2260,16 +2157,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2281,10 +2177,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py index b8eb100a2127..c852b93ed4e2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -164,7 +169,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +180,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum10], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +200,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +215,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum10], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -230,17 +233,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,7 +262,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -272,16 +271,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +291,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -318,12 +312,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,22 +330,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,10 +356,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py index a40775c96eca..9e3f037e3537 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py index 0219685b7836..2411b127983d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py index 8e7954c5cfc0..c75566ad2528 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py index f9a9044c9634..cfb196d19cff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -434,7 +434,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -499,7 +499,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -507,18 +506,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -526,25 +524,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,22 +562,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -594,22 +588,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -632,7 +622,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -640,16 +630,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -663,13 +652,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -698,14 +683,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] @@ -717,7 +694,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -735,18 +712,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] @@ -758,7 +727,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -774,19 +743,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] @@ -818,7 +777,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -828,17 +787,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -853,12 +810,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -872,21 +828,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -896,11 +851,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -925,12 +876,11 @@ def get_properties( data is not included when fetching properties. Currently we only support geoReplicationStats. Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -944,22 +894,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -971,13 +920,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1010,7 +955,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1021,7 +965,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1043,11 +987,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1058,7 +1001,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1078,17 +1021,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1111,7 +1051,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1119,16 +1059,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1140,20 +1079,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1164,7 +1098,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1175,15 +1109,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1194,14 +1127,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1211,11 +1144,11 @@ def extract_data(pipeline_response): 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 @@ -1227,8 +1160,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1237,7 +1168,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1248,7 +1178,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1259,16 +1189,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1279,14 +1208,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1296,11 +1225,11 @@ def extract_data(pipeline_response): 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 @@ -1312,10 +1241,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1329,12 +1254,11 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1348,21 +1272,20 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1374,13 +1297,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1408,7 +1327,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1419,7 +1337,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1435,11 +1353,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1450,7 +1367,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. @@ -1463,18 +1380,14 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. - Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. Required. :type regenerate_key: - ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1497,7 +1410,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1505,16 +1418,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1526,13 +1438,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1559,7 +1467,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1570,7 +1477,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1586,11 +1493,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1601,7 +1507,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1614,17 +1520,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1647,7 +1549,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1655,16 +1557,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1676,13 +1577,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1708,7 +1605,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1719,7 +1615,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1734,11 +1630,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1749,7 +1644,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1762,17 +1657,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1795,7 +1686,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1803,16 +1694,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1824,18 +1714,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1849,21 +1735,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1873,11 +1758,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1892,14 +1773,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1926,7 +1799,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1937,17 +1810,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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1962,12 +1831,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1981,21 +1849,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2005,8 +1872,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py index 66e1e6da8c82..1aa7af3489cb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-11-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py index 79e62afe0e1c..2d275656dfc0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json index f9e4dda6ab11..c47a92dae63d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py index 5b8a8854c9c3..4af127947d76 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -77,7 +79,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -105,7 +125,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2019-04-01" ) - 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 @@ -125,7 +145,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py index 8f5e6c464066..2977f0428576 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py index aa81194862ff..26736d3aec15 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -79,7 +81,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -107,7 +127,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2019-04-01" ) - 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 @@ -127,7 +149,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py index 4d02dbcfe412..3348249ed922 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -97,7 +102,6 @@ def list( :param filter: Optional. When specified, only container names starting with the filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItem] @@ -109,7 +113,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,7 +124,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -128,12 +132,11 @@ def prepare_request(next_link=None): maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -144,14 +147,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -161,11 +164,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 @@ -177,10 +180,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -213,7 +212,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -225,7 +223,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -247,11 +245,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -263,7 +260,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -283,17 +280,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -316,7 +309,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -325,16 +318,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,10 +346,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -389,7 +377,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -401,7 +388,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -422,11 +409,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -438,7 +424,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -457,17 +443,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,7 +472,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -499,16 +481,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -520,13 +501,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -546,12 +523,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -565,22 +541,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -592,13 +567,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -618,12 +589,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -637,22 +607,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -662,11 +631,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -700,7 +665,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -712,7 +676,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -734,11 +698,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -750,7 +713,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -770,17 +733,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -803,7 +762,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -812,16 +771,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -833,13 +791,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -872,7 +826,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -884,7 +837,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -905,11 +858,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -921,7 +873,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -940,17 +892,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -973,7 +921,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -982,16 +930,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1003,13 +950,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1052,7 +995,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1066,7 +1008,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1095,11 +1037,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1113,7 +1054,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1139,17 +1080,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1175,7 +1112,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1186,16 +1123,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1210,13 +1146,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1250,12 +1182,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1269,7 +1200,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1277,16 +1208,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1301,13 +1231,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1343,12 +1269,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1362,7 +1287,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1370,16 +1295,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1394,13 +1318,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1425,12 +1345,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1444,23 +1363,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1475,13 +1393,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1521,7 +1435,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1534,7 +1447,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1561,11 +1474,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1578,7 +1490,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1602,17 +1514,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1638,7 +1546,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1648,16 +1556,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1672,13 +1579,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1711,7 +1614,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1723,7 +1625,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1744,11 +1646,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1760,7 +1661,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1778,18 +1679,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1815,7 +1712,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1824,16 +1721,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1845,10 +1741,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py index 0f4ef570c28e..53725ce113f4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,6 +36,10 @@ build_set_service_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]] @@ -72,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -184,7 +183,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +194,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum16], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -216,11 +214,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -232,7 +229,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum16], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -250,17 +247,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +276,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -292,16 +285,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,13 +305,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -338,12 +326,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,22 +344,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,10 +370,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py index ea507666af81..ca5cd13b1b1b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum16], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum16], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -215,18 +212,14 @@ async def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py index 79cef8403300..fe3eceb971d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -88,7 +93,6 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItem] @@ -100,7 +104,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,7 +115,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -119,12 +123,11 @@ def prepare_request(next_link=None): maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -135,14 +138,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -152,11 +155,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 @@ -168,10 +171,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -204,7 +203,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -216,7 +214,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -238,11 +236,10 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -254,7 +251,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -273,18 +270,14 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +300,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -316,16 +309,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -345,10 +337,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -380,7 +368,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -392,7 +379,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -413,11 +400,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -429,7 +415,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -447,18 +433,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,7 +463,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -490,16 +472,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -511,13 +492,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -537,12 +514,11 @@ async def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,22 +532,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -583,13 +558,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -609,12 +580,11 @@ async def delete( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,22 +598,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -653,8 +622,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py index af556f72d881..840d15da6708 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py index 825150146e90..a1d7a4986eb6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py index f0ab8ed6d048..ac61431cb4af 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,15 +83,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py index 6c733b243279..281947b2a6b3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -48,10 +48,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +94,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -102,18 +101,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -121,25 +119,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,22 +157,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -189,22 +183,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,7 +217,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -235,16 +225,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,13 +247,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -293,14 +278,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -313,7 +290,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -331,18 +308,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -355,7 +324,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -371,19 +340,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -416,7 +375,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -426,17 +385,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -451,12 +408,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,21 +426,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,11 +449,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -523,12 +474,11 @@ async def get_properties( data is not included when fetching properties. Currently we only support geoReplicationStats. Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -542,22 +492,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,13 +518,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -608,7 +553,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -619,7 +563,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -641,11 +585,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -656,7 +599,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -676,17 +619,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -709,7 +649,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -717,16 +657,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,20 +677,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] @@ -763,7 +697,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -774,15 +708,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -793,14 +726,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -810,11 +743,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 @@ -826,8 +759,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -838,7 +769,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] @@ -850,7 +780,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -861,16 +791,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -881,14 +810,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -898,11 +827,11 @@ async def extract_data(pipeline_response): 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 @@ -914,10 +843,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -935,12 +860,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -954,22 +878,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -981,13 +904,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1015,7 +934,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1026,7 +944,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1042,11 +960,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1057,7 +974,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1070,18 +987,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1104,7 +1018,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1112,16 +1026,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,13 +1046,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1166,7 +1075,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1177,7 +1085,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1193,11 +1101,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1208,7 +1115,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1221,17 +1128,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1254,7 +1157,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1262,16 +1165,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1283,13 +1185,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1315,7 +1213,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1326,7 +1223,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1341,11 +1238,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1356,7 +1252,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1369,17 +1265,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1402,7 +1294,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1410,16 +1302,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1431,18 +1322,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1456,21 +1343,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1480,11 +1366,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1499,14 +1381,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1533,7 +1407,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1544,17 +1418,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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1569,12 +1439,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1588,21 +1457,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1612,8 +1480,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py index a19f223fda20..8adaeeafa210 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py index 961dae996730..eb7740eaf82c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -128,7 +122,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -205,7 +199,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. Ex - - /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 @@ -240,7 +234,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -274,7 +268,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -321,7 +315,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -450,7 +444,7 @@ class BlobServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -637,7 +631,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -734,7 +728,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -770,7 +764,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -798,7 +792,7 @@ def __init__(self, *, days_after_creation_greater_than: float, **kwargs: Any) -> class DateAfterModification(_serialization.Model): """Object to define the number of days after last modification. - 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 days_after_modification_greater_than: Value indicating the age in days after last modification. Required. @@ -884,7 +878,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2019_04_01.models.EncryptionServices @@ -1089,7 +1083,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1132,7 +1126,7 @@ class FileShare(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1191,7 +1185,7 @@ class FileShareItem(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1321,7 +1315,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -1358,10 +1352,10 @@ class ImmutabilityPolicy(AzureEntityResource): 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. Ex - - /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 @@ -1459,7 +1453,7 @@ def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -1532,10 +1526,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1574,7 +1568,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1631,7 +1625,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -1726,7 +1720,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1885,7 +1879,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2004,7 +1998,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyAction @@ -2043,7 +2037,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -2075,7 +2069,7 @@ def __init__(self, *, blob_types: List[str], prefix_match: Optional[List[str]] = class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -2132,7 +2126,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -2263,7 +2257,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -2479,7 +2473,7 @@ def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -2670,7 +2664,7 @@ class Sku(_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 name: Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: @@ -2778,10 +2772,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. Ex - - /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 @@ -2826,10 +2820,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -3054,12 +3048,12 @@ def __init__( # pylint: disable=too-many-locals self.allow_shared_key_access = allow_shared_key_access -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -3092,7 +3086,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku @@ -3364,7 +3358,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -3757,10 +3751,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -3790,7 +3784,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py index 987f92f35b12..d2f96238f31a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py @@ -148,7 +148,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py index ab569dee7908..22f6942d6b1b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -293,7 +298,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -597,7 +602,6 @@ def list( :param filter: Optional. When specified, only container names starting with the filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -608,7 +612,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,7 +623,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -627,12 +631,11 @@ def prepare_request(next_link=None): maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -643,14 +646,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -660,11 +663,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 @@ -676,10 +679,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -712,7 +711,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -724,7 +722,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -746,11 +744,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -762,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -782,17 +779,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -815,7 +808,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -824,16 +817,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -853,10 +845,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -888,7 +876,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -900,7 +887,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -921,11 +908,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -937,7 +923,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -956,17 +942,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -989,7 +971,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -998,16 +980,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1019,13 +1000,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1045,12 +1022,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1064,22 +1040,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1091,13 +1066,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1117,12 +1088,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1136,22 +1106,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1161,11 +1130,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1199,7 +1164,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1211,7 +1175,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1233,11 +1197,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1249,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1269,17 +1232,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1302,7 +1261,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1311,16 +1270,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1332,13 +1290,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1371,7 +1325,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1383,7 +1336,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1404,11 +1357,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1420,7 +1372,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1439,17 +1391,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1472,7 +1420,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1481,16 +1429,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1502,13 +1449,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1551,7 +1494,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1565,7 +1507,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1594,11 +1536,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1612,7 +1553,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1638,17 +1579,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1674,7 +1611,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1685,16 +1622,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1709,13 +1645,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1749,12 +1681,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1768,7 +1699,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1776,16 +1707,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1800,13 +1730,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1842,12 +1768,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1861,7 +1786,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1869,16 +1794,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1893,13 +1817,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1924,12 +1844,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1943,23 +1862,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1974,13 +1892,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2020,7 +1934,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2033,7 +1946,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2060,11 +1973,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2077,7 +1989,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2101,17 +2013,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2137,7 +2045,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2147,16 +2055,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2171,13 +2078,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2210,7 +2113,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2222,7 +2124,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2243,11 +2145,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2259,7 +2160,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2277,18 +2178,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2314,7 +2211,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2323,16 +2220,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2344,10 +2240,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py index 6dfb125cce56..9f47cc8752c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -180,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -193,7 +197,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,17 +208,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -225,14 +228,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -242,11 +245,11 @@ def extract_data(pipeline_response): 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 @@ -258,10 +261,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -292,7 +291,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +302,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum16], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,11 +322,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +337,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum16], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -358,17 +355,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +384,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -400,16 +393,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +413,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -446,12 +434,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,22 +452,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,10 +478,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py index 75304ea3a613..4e5ea192885a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum16], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum16], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -324,18 +321,14 @@ def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py index 61d1df977c32..cbd78c8dd045 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -272,7 +277,6 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +287,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,7 +298,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -302,12 +306,11 @@ def prepare_request(next_link=None): maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -318,14 +321,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -335,11 +338,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 @@ -351,10 +354,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -387,7 +386,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -399,7 +397,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -421,11 +419,10 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -437,7 +434,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -456,18 +453,14 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -490,7 +483,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -499,16 +492,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,10 +520,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -563,7 +551,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -575,7 +562,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -596,11 +583,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -612,7 +598,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -630,18 +616,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,7 +646,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -673,16 +655,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -694,13 +675,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any) -> _models.FileShare: @@ -718,12 +695,11 @@ def get(self, resource_group_name: str, account_name: str, share_name: str, **kw dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -737,22 +713,21 @@ def get(self, resource_group_name: str, account_name: str, share_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -764,13 +739,9 @@ def get(self, resource_group_name: str, account_name: str, share_name: str, **kw deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -790,12 +761,11 @@ def delete( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -809,22 +779,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,8 +803,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py index d0ea13759f66..cb4dc603c8ba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py index 15a5cd2fd2f5..b6f8758d542b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py index a8c56e8cff27..af99e9bb342d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Sku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.Sku] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py index 655e14cad2f5..acfb574ee6d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -441,7 +441,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -506,7 +506,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -514,18 +513,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -533,25 +531,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +569,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,22 +595,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,7 +629,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -647,16 +637,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -670,13 +659,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -705,14 +690,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] @@ -724,7 +701,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -742,18 +719,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] @@ -765,7 +734,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -781,19 +750,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] @@ -825,7 +784,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -835,17 +794,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -860,12 +817,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -879,21 +835,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -903,11 +858,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -932,12 +883,11 @@ def get_properties( data is not included when fetching properties. Currently we only support geoReplicationStats. Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -951,22 +901,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -978,13 +927,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1017,7 +962,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1028,7 +972,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1050,11 +994,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1065,7 +1008,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1085,17 +1028,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1118,7 +1058,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1126,16 +1066,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1147,20 +1086,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1171,7 +1105,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1182,15 +1116,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1201,14 +1134,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1218,11 +1151,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 @@ -1234,8 +1167,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1244,7 +1175,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1255,7 +1185,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1266,16 +1196,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1286,14 +1215,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1303,11 +1232,11 @@ def extract_data(pipeline_response): 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 @@ -1319,10 +1248,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1340,12 +1265,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1359,22 +1283,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1386,13 +1309,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1420,7 +1339,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1431,7 +1349,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1447,11 +1365,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1462,7 +1379,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1475,18 +1392,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1509,7 +1423,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1517,16 +1431,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1538,13 +1451,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1571,7 +1480,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1582,7 +1490,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1598,11 +1506,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1613,7 +1520,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1626,17 +1533,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1659,7 +1562,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1667,16 +1570,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1688,13 +1590,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1720,7 +1618,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1731,7 +1628,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1746,11 +1643,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1761,7 +1657,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1774,17 +1670,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1807,7 +1699,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1815,16 +1707,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1836,18 +1727,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1861,21 +1748,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1885,11 +1771,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1904,14 +1786,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1938,7 +1812,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1949,17 +1823,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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1974,12 +1844,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1993,21 +1862,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2017,8 +1885,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py index 209d622d48c2..463a1c56fb07 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py index 713947f87b33..930089579920 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-06-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json index aa03dcf69e0f..d0aad11e8f3c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py index f986197c33b4..6e61963301dc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -109,7 +111,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -160,7 +180,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2019-06-01") - 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 @@ -180,7 +200,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py index 745998a58ef6..1df02180dece 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2019-06-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py index 0b32028e50d3..c9cb501a41f7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -111,7 +113,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -162,7 +182,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2019-06-01") - 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 @@ -182,7 +204,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py index d301bf7ffdf3..fdeb87a361d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -98,7 +103,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2019_06_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItem] @@ -110,7 +114,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +125,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -129,12 +133,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -145,14 +148,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -162,11 +165,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 @@ -178,10 +181,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -214,7 +213,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -226,7 +224,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -248,11 +246,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +261,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -284,17 +281,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -317,7 +310,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -326,16 +319,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +347,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -390,7 +378,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -402,7 +389,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -423,11 +410,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -439,7 +425,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -458,17 +444,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +473,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -500,16 +482,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,13 +502,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -547,12 +524,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,22 +542,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -593,13 +568,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -619,12 +590,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,22 +608,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -663,11 +632,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -701,7 +666,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -713,7 +677,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -735,11 +699,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -751,7 +714,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -771,17 +734,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -804,7 +763,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -813,16 +772,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,13 +792,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -873,7 +827,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -885,7 +838,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -906,11 +859,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -922,7 +874,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -941,17 +893,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -974,7 +922,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -983,16 +931,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,13 +951,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1053,7 +996,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1067,7 +1009,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1096,11 +1038,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1114,7 +1055,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1140,17 +1081,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1176,7 +1113,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1187,16 +1124,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1211,13 +1147,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1251,12 +1183,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1270,7 +1201,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1278,16 +1209,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1302,13 +1232,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1344,12 +1270,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1363,7 +1288,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1371,16 +1296,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1395,13 +1319,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1426,12 +1346,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1445,23 +1364,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1476,13 +1394,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1522,7 +1436,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1448,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1562,11 +1475,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1579,7 +1491,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1603,17 +1515,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1639,7 +1547,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1649,16 +1557,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1673,13 +1580,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1712,7 +1615,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1724,7 +1626,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1745,11 +1647,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1761,7 +1662,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1779,18 +1680,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1816,7 +1713,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1825,16 +1722,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1846,10 +1742,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py index 87ca5966f561..a907a7ef28cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +131,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +164,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +194,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +209,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -229,17 +226,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +255,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -271,16 +264,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +353,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +368,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy] @@ -398,7 +379,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +390,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +410,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -447,11 +427,11 @@ async def extract_data(pipeline_response): 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 @@ -463,7 +443,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py index 7d5af59b4995..f99fe53d90cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,6 +36,10 @@ build_set_service_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]] @@ -72,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -184,7 +183,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +194,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -216,11 +214,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -232,7 +229,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum27], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -250,17 +247,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +276,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -292,16 +285,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,13 +305,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -338,12 +326,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,22 +344,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,10 +370,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py index 71d9c1c6b4b3..9125fbbed8ba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py index efbb94ee1852..b1eea16c4f84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum27], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -215,18 +212,14 @@ async def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py index 8500157c8dfd..4c7b6c438832 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,10 +39,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are "deleted" and None. Default value is "deleted". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItem] @@ -107,7 +106,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -118,7 +117,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -126,12 +125,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -142,14 +140,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -159,11 +157,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 @@ -175,10 +173,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -211,7 +205,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -223,7 +216,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -245,11 +238,10 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -261,7 +253,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -280,18 +272,14 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -314,7 +302,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -323,16 +311,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -352,10 +339,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -387,7 +370,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -399,7 +381,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -420,11 +402,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -436,7 +417,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -454,18 +435,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,7 +465,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -497,16 +474,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -518,13 +494,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -552,12 +524,11 @@ async def get( :param expand: Optional, used to expand the properties within share's properties. Known values are "stats" and None. Default value is "stats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -571,23 +542,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, expand=expand, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,13 +569,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -625,12 +591,11 @@ async def delete( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -644,22 +609,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -669,11 +633,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -705,7 +665,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -717,7 +676,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -737,11 +696,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -753,7 +711,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -770,17 +728,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -803,7 +757,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -812,16 +766,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -831,8 +784,4 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py index a68fde17e734..7c0e0e7c3858 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py index 1868b3f7def5..fcd43b94baa9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -172,12 +171,11 @@ async def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,22 +189,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -219,13 +216,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -256,7 +249,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -268,7 +260,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -287,11 +279,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -303,7 +294,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -319,17 +310,14 @@ async def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,7 +340,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -361,16 +349,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,13 +370,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -407,12 +390,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,22 +408,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -452,8 +433,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py index 69650e7f72b8..273b31c2bb01 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py index cafe0018b3cf..67d772564818 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.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.storage.v2019_06_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py index d9cee211ea12..ea7dae57af8b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2019_06_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py index 8f11d7a9857d..7c6f1dbcb3f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py index 869816cdb12c..09ff686365bd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum27], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -216,17 +213,13 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py index 9fb66d9a74e8..4da075450ce4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py index 7b6d4a8d3291..b0834c0b1e89 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,18 +102,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -122,25 +120,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,22 +158,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,22 +184,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +218,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -236,16 +226,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,13 +248,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -294,14 +279,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -314,7 +291,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,18 +309,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -356,7 +325,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -372,19 +341,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -417,7 +376,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -427,17 +386,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -452,12 +409,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,21 +427,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,11 +450,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -525,12 +476,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2019_06_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -544,22 +494,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,13 +520,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -610,7 +555,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -621,7 +565,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -643,11 +587,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -658,7 +601,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -678,17 +621,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +651,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -719,16 +659,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,20 +679,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] @@ -765,7 +699,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,15 +710,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -795,14 +728,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -812,11 +745,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 @@ -828,8 +761,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -840,7 +771,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] @@ -852,7 +782,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,16 +793,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -883,14 +812,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -900,11 +829,11 @@ async def extract_data(pipeline_response): 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 @@ -916,10 +845,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -937,12 +862,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,22 +880,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -983,13 +906,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1017,7 +936,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1028,7 +946,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1044,11 +962,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1059,7 +976,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1072,18 +989,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1020,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1114,16 +1028,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1135,13 +1048,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1168,7 +1077,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1179,7 +1087,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1195,11 +1103,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1210,7 +1117,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1223,17 +1130,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1256,7 +1159,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1264,16 +1167,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1285,13 +1187,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1317,7 +1215,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1328,7 +1225,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1343,11 +1240,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1358,7 +1254,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1371,17 +1267,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1404,7 +1296,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1412,16 +1304,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1433,18 +1324,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1458,21 +1345,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,11 +1368,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1501,14 +1383,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1535,7 +1409,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1546,26 +1420,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1588,7 +1458,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1596,16 +1466,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1625,10 +1494,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1653,14 +1518,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1673,7 +1530,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1688,18 +1545,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1712,7 +1561,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1725,19 +1574,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -1770,7 +1608,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1782,17 +1620,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1807,12 +1643,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,21 +1661,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1850,8 +1684,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py index 51d386e9b0cc..77d60a0f77f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -148,12 +147,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,22 +165,21 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,13 +191,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -217,12 +210,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,22 +228,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -263,13 +254,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -288,12 +275,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,22 +293,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,11 +317,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -349,7 +330,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -360,7 +340,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,17 +351,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -392,14 +371,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -409,11 +388,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 @@ -424,7 +403,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py index d33700fbb57d..c963d9020144 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum27], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -216,17 +213,13 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py index 6d01997bc39f..b6ec73020f96 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py index d354e13264c4..d06c275402f9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -128,7 +122,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -205,7 +199,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. Ex - - /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 @@ -240,7 +234,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -274,7 +268,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -321,7 +315,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -465,7 +459,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -512,7 +506,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. - 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 filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyFilter @@ -538,7 +532,7 @@ def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs: An class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. - 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 prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] @@ -593,7 +587,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -637,7 +631,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -696,7 +690,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -731,7 +725,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -831,7 +825,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1081,7 +1075,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1178,7 +1172,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1214,7 +1208,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1286,7 +1280,7 @@ def __init__( class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1381,7 +1375,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2019_06_01.models.EncryptionServices @@ -1442,7 +1436,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1813,7 +1807,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1878,7 +1872,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2006,7 +2000,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2205,7 +2199,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2243,7 +2237,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2380,7 +2374,7 @@ def __init__( class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -2469,7 +2463,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -2529,10 +2523,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2571,7 +2565,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -2628,7 +2622,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -2746,7 +2740,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2920,7 +2914,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3084,7 +3078,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3220,7 +3214,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyAction @@ -3259,7 +3253,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -3308,7 +3302,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -3365,7 +3359,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -3562,7 +3556,7 @@ def __init__( class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -3647,7 +3641,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3746,7 +3740,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -3940,7 +3934,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4025,7 +4019,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. Ex - - /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 @@ -4140,7 +4134,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4182,7 +4176,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -4315,7 +4309,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -4506,7 +4500,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -4576,7 +4570,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -4654,10 +4648,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. Ex - - /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 @@ -4702,10 +4696,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -4954,12 +4948,12 @@ def __init__( # pylint: disable=too-many-locals self.allow_shared_key_access = allow_shared_key_access -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -4992,7 +4986,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku @@ -5361,7 +5355,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -5562,7 +5556,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5695,7 +5689,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5732,7 +5726,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5772,7 +5766,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -5997,10 +5991,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -6030,7 +6024,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py index 34de227f647d..271d93200c6f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py @@ -215,7 +215,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py index b19d566cb0ef..26b074873968 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -293,7 +298,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -598,7 +603,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2019_06_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -609,7 +613,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -620,7 +624,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -628,12 +632,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -644,14 +647,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -661,11 +664,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 @@ -677,10 +680,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -713,7 +712,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -725,7 +723,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -747,11 +745,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -763,7 +760,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -783,17 +780,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +809,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -825,16 +818,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,10 +846,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -889,7 +877,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -901,7 +888,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -922,11 +909,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -938,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -957,17 +943,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -990,7 +972,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -999,16 +981,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,13 +1001,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1046,12 +1023,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1065,22 +1041,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1092,13 +1067,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1118,12 +1089,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1137,22 +1107,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1162,11 +1131,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1200,7 +1165,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1176,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1234,11 +1198,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1250,7 +1213,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1270,17 +1233,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,7 +1262,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1312,16 +1271,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1333,13 +1291,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1372,7 +1326,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1384,7 +1337,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1405,11 +1358,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1421,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1440,17 +1392,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1473,7 +1421,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1482,16 +1430,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1503,13 +1450,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1552,7 +1495,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1508,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1595,11 +1537,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1613,7 +1554,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1639,17 +1580,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1675,7 +1612,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1686,16 +1623,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1710,13 +1646,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1750,12 +1682,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1769,7 +1700,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1777,16 +1708,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1801,13 +1731,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1843,12 +1769,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1862,7 +1787,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1870,16 +1795,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1894,13 +1818,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1925,12 +1845,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1944,23 +1863,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1975,13 +1893,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2021,7 +1935,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2034,7 +1947,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2061,11 +1974,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2078,7 +1990,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2102,17 +2014,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2138,7 +2046,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2148,16 +2056,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2172,13 +2079,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2211,7 +2114,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2223,7 +2125,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2244,11 +2146,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2260,7 +2161,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2278,18 +2179,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2315,7 +2212,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2324,16 +2221,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2345,10 +2241,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py index 62e7d99bb720..383488aaa12b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +276,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -310,7 +309,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +339,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,7 +354,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -374,17 +371,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +400,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -416,16 +409,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,13 +430,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -467,12 +455,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,22 +473,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,11 +498,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -531,7 +513,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy] @@ -543,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +535,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +555,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -592,11 +572,11 @@ def extract_data(pipeline_response): 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 @@ -608,7 +588,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py index 663f241608ea..41e0e68b4474 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -180,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -193,7 +197,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,17 +208,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -225,14 +228,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -242,11 +245,11 @@ def extract_data(pipeline_response): 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 @@ -258,10 +261,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -292,7 +291,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +302,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,11 +322,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +337,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum27], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -358,17 +355,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +384,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -400,16 +393,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +413,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -446,12 +434,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,22 +452,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,10 +478,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py index 46f505a58a75..b224181206c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py index 23d54cce60aa..772b2df7e48d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum27], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -324,18 +321,14 @@ def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py index 47a48a364fa0..fd68206b02f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -323,7 +323,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are "deleted" and None. Default value is "deleted". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -334,7 +333,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,7 +344,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -353,12 +352,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -369,14 +367,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -386,11 +384,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 @@ -402,10 +400,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -438,7 +432,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -450,7 +443,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -472,11 +465,10 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -488,7 +480,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -507,18 +499,14 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +529,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -550,16 +538,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -579,10 +566,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -614,7 +597,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -626,7 +608,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -647,11 +629,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -663,7 +644,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -681,18 +662,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +692,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -724,16 +701,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -745,13 +721,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -779,12 +751,11 @@ def get( :param expand: Optional, used to expand the properties within share's properties. Known values are "stats" and None. Default value is "stats". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -798,23 +769,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, expand=expand, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -826,13 +796,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -852,12 +818,11 @@ def delete( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -871,22 +836,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -896,11 +860,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -932,7 +892,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -944,7 +903,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -964,11 +923,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -980,7 +938,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -997,17 +955,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1030,7 +984,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1039,16 +993,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1058,8 +1011,4 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py index 223e41c14da8..09fccc66fd88 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py index b86c20207636..3f8ed2716e0d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -311,12 +310,11 @@ def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,22 +328,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,13 +355,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -395,7 +388,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -407,7 +399,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -426,11 +418,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +433,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -458,17 +449,14 @@ def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +479,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -500,16 +488,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,13 +509,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -546,12 +529,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -565,22 +547,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,8 +572,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py index f68be6d8ce92..848de31c5919 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py index def92ff6e598..f584679a3829 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2019_06_01.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.storage.v2019_06_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py index f5798e1b8a0c..c081e4990f0b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2019_06_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py index 6a876a7f10dc..ef778e515b97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py index b15443be66f4..46a31e5e7a59 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum27], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -325,17 +322,13 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py index 004b055ed282..ede0ac1a0502 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py index af5b7971b540..3c90c87564a3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -477,7 +477,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -542,7 +542,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -550,18 +549,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -569,25 +567,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -610,22 +605,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -637,22 +631,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +665,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -683,16 +673,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -706,13 +695,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -741,14 +726,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] @@ -760,7 +737,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -778,18 +755,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] @@ -801,7 +770,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -817,19 +786,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] @@ -861,7 +820,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -871,17 +830,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -896,12 +853,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,21 +871,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -939,11 +894,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -969,12 +920,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2019_06_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,22 +938,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1015,13 +964,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1054,7 +999,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1065,7 +1009,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1087,11 +1031,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1102,7 +1045,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1122,17 +1065,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1155,7 +1095,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1163,16 +1103,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1184,20 +1123,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1208,7 +1142,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1219,15 +1153,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1238,14 +1171,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1255,11 +1188,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 @@ -1271,8 +1204,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1281,7 +1212,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1292,7 +1222,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,16 +1233,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1323,14 +1252,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1340,11 +1269,11 @@ def extract_data(pipeline_response): 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 @@ -1356,10 +1285,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1377,12 +1302,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1396,22 +1320,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1423,13 +1346,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1457,7 +1376,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1468,7 +1386,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1484,11 +1402,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1499,7 +1416,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1512,18 +1429,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1546,7 +1460,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1554,16 +1468,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1575,13 +1488,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1608,7 +1517,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1619,7 +1527,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1635,11 +1543,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1650,7 +1557,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1663,17 +1570,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1696,7 +1599,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1704,16 +1607,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1725,13 +1627,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1757,7 +1655,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1768,7 +1665,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1783,11 +1680,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1798,7 +1694,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1811,17 +1707,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1844,7 +1736,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1852,16 +1744,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1873,18 +1764,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1898,21 +1785,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1922,11 +1808,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1941,14 +1823,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1975,7 +1849,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1986,26 +1860,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2028,7 +1898,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2036,16 +1906,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2065,10 +1934,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2093,14 +1958,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] @@ -2112,7 +1969,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2127,18 +1984,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] @@ -2150,7 +1999,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2163,19 +2012,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] @@ -2207,7 +2045,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2219,17 +2057,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2244,12 +2080,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2263,21 +2098,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2287,8 +2121,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py index 250928a811f8..a1d00fa23277 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,22 +269,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,13 +295,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -315,12 +314,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,22 +332,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,13 +358,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -384,12 +377,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,22 +395,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,13 +421,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -455,12 +442,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,22 +460,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,11 +484,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -516,7 +497,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -527,7 +507,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,17 +518,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +538,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -576,11 +555,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 @@ -591,7 +570,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py index ac6e7d458f46..dce21ddd62f1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum27], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum27], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -325,17 +322,13 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py index 878551952492..f58068ac963b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-06-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py index c7c22aa178f7..4a0b3e35fc17 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-08-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json index 923af12f8e57..aa914ce4517e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py index f3906762d14d..a43fa08fb3ec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -119,7 +121,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -181,7 +201,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-08-01-preview" ) - 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 @@ -201,7 +221,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py index adf922aff6a6..bdc48c02393e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-08-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py index 70601f37e04d..483b44c7d8ca 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -120,7 +122,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -182,7 +202,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2020-08-01-preview" ) - 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 @@ -202,7 +224,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py index 586ad73b551a..f98aac7ed733 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -98,7 +103,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItem] @@ -112,7 +116,7 @@ def list( ) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,7 +127,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -131,12 +135,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -147,14 +150,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -164,11 +167,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 @@ -180,10 +183,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -216,7 +215,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -228,7 +226,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -250,11 +248,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -286,17 +283,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,7 +314,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -330,16 +323,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -359,10 +351,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -394,7 +382,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -406,7 +393,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -427,11 +414,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -443,7 +429,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -462,17 +448,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -497,7 +479,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -506,16 +488,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -527,13 +508,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -553,12 +530,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +550,21 @@ async def get( ) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +576,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +598,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,22 +618,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -673,11 +642,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -711,7 +676,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -723,7 +687,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -745,11 +709,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -761,7 +724,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -781,17 +744,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +775,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -825,16 +784,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -846,13 +804,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -885,7 +839,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -897,7 +850,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -918,11 +871,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -934,7 +886,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -953,17 +905,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,7 +936,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -997,16 +945,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1018,13 +965,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1067,7 +1010,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1081,7 +1023,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1110,11 +1052,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1128,7 +1069,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1154,17 +1095,14 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1192,7 +1130,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1203,16 +1141,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1227,13 +1164,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1267,12 +1200,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1288,7 +1220,7 @@ async def get_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1296,16 +1228,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1320,13 +1251,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1362,12 +1289,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1383,7 +1309,7 @@ async def delete_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1391,16 +1317,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1415,13 +1340,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1446,12 +1367,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1467,23 +1387,22 @@ async def lock_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1498,13 +1417,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1544,7 +1459,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1557,7 +1471,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1584,11 +1498,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1601,7 +1514,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1625,17 +1538,14 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1663,7 +1573,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1673,16 +1583,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1697,13 +1606,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1736,7 +1641,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1748,7 +1652,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1769,11 +1673,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1785,7 +1688,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1803,18 +1706,15 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest or + IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1842,7 +1742,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1851,16 +1751,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1872,10 +1771,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py index 4677d61dfc8e..b98a53175929 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,22 +106,21 @@ async def get( ) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,13 +133,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -167,7 +166,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -179,7 +177,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -198,11 +196,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -214,7 +211,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -231,17 +228,14 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy or + IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,7 +260,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -275,16 +269,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -297,13 +290,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -326,12 +315,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,22 +335,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,11 +360,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -392,7 +375,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy] @@ -406,7 +388,7 @@ def list( ) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -417,17 +399,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -438,14 +419,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -455,11 +436,11 @@ async def extract_data(pipeline_response): 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 @@ -471,7 +452,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py index 260a5efd57e2..bcd6febea05d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,6 +36,10 @@ build_set_service_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]] @@ -72,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -87,7 +91,7 @@ def list( ) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,17 +102,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -136,11 +139,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -186,7 +185,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +196,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -218,11 +216,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +231,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum28], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -252,17 +249,14 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties or + IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,7 +281,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -296,16 +290,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -317,13 +310,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -342,12 +331,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,22 +351,21 @@ async def get_service_properties( ) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,10 +377,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py index 7ea170035e14..c3602679dd2d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount] @@ -72,7 +76,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: ) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,15 +87,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -119,11 +122,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 @@ -136,8 +139,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -146,12 +147,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,21 +167,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> ) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,10 +193,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py index d51183255cd7..f619f3c3646c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,14 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope or + IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,7 +199,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -208,16 +208,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -238,10 +237,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -273,7 +268,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -285,7 +279,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -306,11 +300,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +315,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -341,17 +334,14 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope or + IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -376,7 +366,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -385,16 +375,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -407,13 +396,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -433,12 +418,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,22 +438,21 @@ async def get( ) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -482,13 +465,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -503,7 +482,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope] @@ -517,7 +495,7 @@ def list( ) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,17 +506,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -549,14 +526,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -566,11 +543,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 @@ -581,7 +558,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py index 7b6c23a7044e..e64ba9df11df 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +92,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) ) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,13 +117,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -152,7 +151,6 @@ async def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -164,7 +162,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -184,11 +182,10 @@ async def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +197,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum28], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -217,18 +214,15 @@ async def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties or + IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,7 +247,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -262,16 +256,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,13 +276,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -308,12 +297,11 @@ async def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,22 +317,21 @@ async def get_service_properties( ) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,10 +343,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py index 5e12d435bf22..2118a2e7f253 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,10 +39,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListSharesExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItem] @@ -109,7 +108,7 @@ def list( ) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -128,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -144,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -161,11 +159,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 @@ -177,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -217,7 +211,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -229,7 +222,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Literal["snapshots"] = "snapshots", *, content_type: str = "application/json", @@ -252,14 +245,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. Default value is "snapshots". :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Literal["snapshots"] = "snapshots", **kwargs: Any ) -> _models.FileShare: @@ -291,21 +283,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO[bytes] :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. Default value is "snapshots". :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,7 +318,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -340,16 +328,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,10 +356,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -404,7 +387,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -416,7 +398,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -437,11 +419,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -453,7 +434,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -471,18 +452,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,7 +484,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -516,16 +493,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -537,13 +513,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -575,12 +547,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -596,7 +567,7 @@ async def get( ) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -604,16 +575,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -625,13 +595,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -658,12 +624,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -679,23 +644,22 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, x_ms_snapshot=x_ms_snapshot, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -705,11 +669,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -741,7 +701,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -753,7 +712,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -773,11 +732,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -789,7 +747,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -806,17 +764,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -841,7 +795,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -850,16 +804,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -869,8 +822,4 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py index 5d4e266cb8f7..4ac109494771 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,22 +102,21 @@ async def get( ) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,13 +128,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -162,7 +161,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -174,7 +172,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -193,11 +191,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -209,7 +206,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -226,17 +223,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,7 +254,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -270,16 +263,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,13 +283,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -320,12 +308,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -366,8 +352,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py index 50ac16ccc0f4..79a71a5f1b54 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -88,7 +92,7 @@ def list( ) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,17 +103,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -120,14 +123,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -137,11 +140,11 @@ async def extract_data(pipeline_response): 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 @@ -154,10 +157,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,22 +193,21 @@ async def get( ) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,13 +220,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +283,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +298,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -323,17 +314,15 @@ async def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy or + IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +347,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -367,16 +356,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,13 +377,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -413,12 +397,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +417,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,8 +442,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py index 8bce7e7fb68b..4835404a9ab8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Operation] @@ -71,7 +75,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,14 +86,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -117,11 +120,11 @@ async def extract_data(pipeline_response): 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 @@ -132,5 +135,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py index f97a979c78c4..58c3267e41bc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -88,7 +92,7 @@ def list( ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,17 +103,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -120,14 +123,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -137,11 +140,11 @@ async def extract_data(pipeline_response): 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 @@ -153,10 +156,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -173,12 +172,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,22 +192,21 @@ async def get( ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,13 +219,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -258,7 +251,6 @@ async def put( :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.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +262,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -288,11 +280,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +295,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -320,18 +311,14 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.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 + IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -356,7 +343,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -365,16 +352,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +373,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -411,12 +393,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +413,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,8 +438,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py index 0e79d3dd17ba..73610cec0dcb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2020_08_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,21 +89,20 @@ async def list_by_storage_account( ) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -111,10 +114,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py index 4f111f72358d..05788b2ca6dc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,7 +191,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -201,16 +200,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,13 +220,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -260,7 +254,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +265,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,11 +285,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +300,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -326,17 +318,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -361,7 +349,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -370,16 +358,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -417,12 +400,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,22 +420,21 @@ async def get( ) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -465,13 +446,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -491,12 +468,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,22 +488,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -537,11 +512,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -567,7 +538,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueue] @@ -581,7 +551,7 @@ def list( ) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -592,19 +562,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -615,14 +584,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -632,11 +601,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 @@ -647,7 +616,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py index 2fac0c38cb0c..6d01f35b496e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +92,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) ) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,13 +117,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -152,7 +151,6 @@ async def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -164,7 +162,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -184,11 +182,10 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +197,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum28], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -218,17 +215,14 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties or + IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,7 +247,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -262,16 +256,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,13 +276,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -308,12 +297,11 @@ async def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,22 +317,21 @@ async def get_service_properties( ) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,10 +343,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py index 9ebde4b417ad..b3bb656f8255 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.SkuInformation] @@ -71,7 +75,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: ) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,15 +86,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -101,14 +104,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -118,11 +121,11 @@ async def extract_data(pipeline_response): 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 @@ -133,5 +136,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py index 4dbfac69504f..363b88ab9e6c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,18 +102,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -122,26 +120,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -193,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,7 +222,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -241,16 +230,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,13 +252,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -299,14 +283,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -319,7 +295,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -337,18 +313,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -361,7 +329,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -377,20 +345,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. + StorageAccountCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCreateParameters - 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. + or IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -425,7 +382,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -435,17 +392,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -460,12 +415,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -481,21 +435,20 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,11 +458,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -535,12 +484,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,22 +504,21 @@ async def get_properties( ) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -583,13 +530,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -622,7 +565,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -633,7 +575,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -655,11 +597,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -670,7 +611,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -690,18 +631,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. + StorageAccountUpdateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountUpdateParameters - 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 + or IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -726,7 +663,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -734,16 +671,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -755,20 +691,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] @@ -782,7 +713,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -793,15 +724,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -812,14 +742,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -829,11 +759,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 @@ -845,8 +775,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -857,7 +785,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] @@ -871,7 +798,7 @@ def list_by_resource_group( ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -882,16 +809,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -902,14 +828,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -919,11 +845,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 @@ -935,10 +861,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -956,12 +878,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -977,22 +898,21 @@ async def list_keys( ) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,13 +924,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1038,7 +954,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1049,7 +964,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1065,11 +980,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1080,7 +994,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1093,18 +1007,16 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters or + IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1129,7 +1041,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1137,16 +1049,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1158,13 +1069,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1191,7 +1098,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1202,7 +1108,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1218,11 +1124,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1233,7 +1138,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1246,17 +1151,14 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters or + IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1281,7 +1183,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1289,16 +1191,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1310,13 +1211,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1342,7 +1239,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1353,7 +1249,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1368,11 +1264,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1383,7 +1278,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1396,17 +1291,14 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters or + IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1431,7 +1323,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1439,16 +1331,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1460,18 +1351,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1487,21 +1374,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1511,11 +1397,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1530,14 +1412,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1566,7 +1440,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1577,26 +1451,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1621,7 +1491,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1629,16 +1499,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1658,10 +1527,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1686,14 +1551,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1706,7 +1563,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1721,18 +1578,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1745,7 +1594,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1758,19 +1607,9 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -1805,7 +1644,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1817,17 +1656,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1842,12 +1679,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1863,21 +1699,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1887,8 +1722,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py index 32d7beebcc07..443e4d78b252 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,22 +102,21 @@ async def create( ) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,13 +128,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -150,12 +149,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -171,22 +169,21 @@ async def update( ) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,13 +195,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -221,12 +214,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,22 +234,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str ) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -269,13 +260,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -294,12 +281,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -315,22 +301,21 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -340,11 +325,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -357,7 +338,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Table] @@ -371,7 +351,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As ) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,17 +362,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -403,14 +382,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -420,11 +399,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 @@ -435,7 +414,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py index d109e118d828..a45a3c823c00 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +92,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) ) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,13 +117,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -152,7 +151,6 @@ async def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -164,7 +162,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -184,11 +182,10 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +197,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum28], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -218,17 +215,14 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties or + IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,7 +247,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -262,16 +256,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,13 +276,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -308,12 +297,11 @@ async def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,22 +317,21 @@ async def get_service_properties( ) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,10 +343,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py index 9db0c73cb895..ffc4af115fde 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Usage] @@ -74,7 +78,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,16 +89,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -105,14 +108,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -122,11 +125,11 @@ async def extract_data(pipeline_response): 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 @@ -137,7 +140,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py index 6fe9296710e5..acc1698eb30c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -130,7 +124,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -207,7 +201,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. Ex - - /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 @@ -242,7 +236,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -276,7 +270,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -323,7 +317,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -467,7 +461,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -514,7 +508,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. - 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 filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyFilter @@ -540,7 +534,7 @@ def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs: An class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. - 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 prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] @@ -595,7 +589,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -641,7 +635,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -700,7 +694,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -735,7 +729,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -836,7 +830,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1088,7 +1082,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1185,7 +1179,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1221,7 +1215,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1297,7 +1291,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. Ex - - /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 @@ -1306,22 +1300,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1329,7 +1307,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1413,7 +1391,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1508,7 +1486,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionServices @@ -1571,7 +1549,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1974,7 +1952,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2046,7 +2024,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2182,7 +2160,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2389,7 +2367,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2427,7 +2405,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2565,7 +2543,7 @@ def __init__( class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -2654,7 +2632,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -2714,10 +2692,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -2757,7 +2735,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -2815,7 +2793,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -2933,7 +2911,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3107,7 +3085,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3271,7 +3249,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3408,7 +3386,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyAction @@ -3447,7 +3425,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -3496,7 +3474,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -3554,7 +3532,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -3771,7 +3749,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -3866,7 +3844,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3967,7 +3945,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -4164,7 +4142,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4250,7 +4228,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. Ex - - /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 @@ -4385,7 +4363,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4453,7 +4431,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -4586,7 +4564,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -4777,7 +4755,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -4847,7 +4825,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -4945,10 +4923,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. Ex - - /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 @@ -4993,10 +4971,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -5257,12 +5235,12 @@ def __init__( # pylint: disable=too-many-locals self.allow_shared_key_access = allow_shared_key_access -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -5295,7 +5273,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku @@ -5677,7 +5655,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -5880,7 +5858,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6015,7 +5993,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6052,7 +6030,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6092,7 +6070,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -6318,10 +6296,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -6351,7 +6329,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py index a82ef09b3b72..f688469021e7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py @@ -221,7 +221,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py index a26db1ada188..2c4ecd8123c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -293,7 +298,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -598,7 +603,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItem] @@ -612,7 +616,7 @@ def list( ) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,7 +627,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -631,12 +635,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -647,14 +650,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -664,11 +667,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 @@ -680,10 +683,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -716,7 +715,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -728,7 +726,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -750,11 +748,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -766,7 +763,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -786,17 +783,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -821,7 +814,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -830,16 +823,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -859,10 +851,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -894,7 +882,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -906,7 +893,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -927,11 +914,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -943,7 +929,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -962,17 +948,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -997,7 +979,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1006,16 +988,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1027,13 +1008,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1053,12 +1030,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1074,22 +1050,21 @@ def get( ) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1101,13 +1076,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1127,12 +1098,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1148,22 +1118,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1173,11 +1142,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1211,7 +1176,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1223,7 +1187,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1245,11 +1209,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1261,7 +1224,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1281,17 +1244,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1316,7 +1275,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1325,16 +1284,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1346,13 +1304,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1385,7 +1339,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1397,7 +1350,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1418,11 +1371,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1434,7 +1386,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1453,17 +1405,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1488,7 +1436,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1497,16 +1445,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1518,13 +1465,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1567,7 +1510,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1581,7 +1523,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1610,11 +1552,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1628,7 +1569,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1654,17 +1595,14 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1692,7 +1630,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1703,16 +1641,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1727,13 +1664,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1767,12 +1700,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1788,7 +1720,7 @@ def get_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1796,16 +1728,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1820,13 +1751,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1862,12 +1789,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1883,7 +1809,7 @@ def delete_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1891,16 +1817,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1915,13 +1840,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1946,12 +1867,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1967,23 +1887,22 @@ def lock_immutability_policy( ) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1998,13 +1917,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2044,7 +1959,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2057,7 +1971,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2084,11 +1998,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2101,7 +2014,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2125,17 +2038,14 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy or + IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2163,7 +2073,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2173,16 +2083,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2197,13 +2106,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2236,7 +2141,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2248,7 +2152,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2269,11 +2173,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2285,7 +2188,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2303,18 +2206,15 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest or + IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2342,7 +2242,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2351,16 +2251,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2372,10 +2271,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py index 938484f79502..053fd6adda7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,22 +251,21 @@ def get( ) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -275,13 +278,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -312,7 +311,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +322,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -343,11 +341,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -359,7 +356,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -376,17 +373,14 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy or + IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,7 +405,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -420,16 +414,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -442,13 +435,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -471,12 +460,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -492,22 +480,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -518,11 +505,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -537,7 +520,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy] @@ -551,7 +533,7 @@ def list( ) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,17 +544,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -583,14 +564,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -600,11 +581,11 @@ def extract_data(pipeline_response): 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 @@ -616,7 +597,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py index fc0beb428162..aa511729e290 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -180,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -195,7 +199,7 @@ def list( ) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,17 +210,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -227,14 +230,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -244,11 +247,11 @@ def extract_data(pipeline_response): 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 @@ -260,10 +263,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -294,7 +293,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -326,11 +324,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -342,7 +339,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum28], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -360,17 +357,14 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties or + IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,7 +389,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -404,16 +398,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -425,13 +418,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -450,12 +439,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,22 +459,21 @@ def get_service_properties( ) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -498,10 +485,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py index b0523545c2a4..432f4d79565b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount] @@ -129,7 +133,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: ) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,15 +144,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -159,14 +162,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -176,11 +179,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 @@ -193,8 +196,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -203,12 +204,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -224,21 +224,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model ) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,10 +250,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py index b48c4d353ba3..4e05f0076ced 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,14 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope or + IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,7 +341,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -350,16 +350,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,10 +379,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -415,7 +410,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -427,7 +421,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -448,11 +442,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -464,7 +457,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -483,17 +476,14 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope or + IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -518,7 +508,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -527,16 +517,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -549,13 +538,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -575,12 +560,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -596,22 +580,21 @@ def get( ) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -624,13 +607,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -643,7 +622,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope] @@ -657,7 +635,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It ) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,17 +646,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -689,14 +666,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -706,11 +683,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 @@ -721,7 +698,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py index 8c518b84fd1e..11490693aa44 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,21 +201,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m ) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,13 +226,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -261,7 +260,6 @@ def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +271,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +291,10 @@ def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +306,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum28], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -326,18 +323,15 @@ def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties or + IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -362,7 +356,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -371,16 +365,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,13 +385,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -417,12 +406,11 @@ def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,22 +426,21 @@ def get_service_properties( ) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -465,10 +452,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py index f6dfc74b0159..98b4e75641aa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -342,7 +342,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListSharesExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItem] @@ -356,7 +355,7 @@ def list( ) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +366,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -375,12 +374,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -391,14 +389,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -408,11 +406,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 @@ -424,10 +422,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -464,7 +458,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -476,7 +469,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Literal["snapshots"] = "snapshots", *, content_type: str = "application/json", @@ -499,14 +492,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. Default value is "snapshots". :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -518,7 +510,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Literal["snapshots"] = "snapshots", **kwargs: Any ) -> _models.FileShare: @@ -538,21 +530,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO[bytes] :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. Default value is "snapshots". :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,7 +565,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -587,16 +575,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -616,10 +603,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -651,7 +634,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -663,7 +645,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -684,11 +666,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -700,7 +681,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -718,18 +699,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -754,7 +731,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -763,16 +740,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -784,13 +760,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -822,12 +794,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +814,7 @@ def get( ) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -851,16 +822,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -872,13 +842,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -905,12 +871,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -926,23 +891,22 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, x_ms_snapshot=x_ms_snapshot, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -952,11 +916,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -988,7 +948,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1000,7 +959,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1020,11 +979,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1036,7 +994,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1053,17 +1011,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1088,7 +1042,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1097,16 +1051,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1116,8 +1069,4 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py index dba49ae6ace6..6720a9832d70 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,22 +212,21 @@ def get( ) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,13 +238,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -272,7 +271,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -284,7 +282,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -303,11 +301,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -319,7 +316,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -336,17 +333,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,7 +364,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -380,16 +373,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,13 +393,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -430,12 +418,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -451,22 +438,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,8 +462,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py index dceb5413ea81..4d707556f90d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -227,7 +231,7 @@ def list( ) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,17 +242,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -259,14 +262,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -276,11 +279,11 @@ def extract_data(pipeline_response): 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 @@ -293,10 +296,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,22 +332,21 @@ def get( ) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,13 +359,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +422,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +437,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -462,17 +453,15 @@ def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy or + IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -497,7 +486,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -506,16 +495,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +516,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -552,12 +536,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -573,22 +556,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,8 +581,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py index b5c1cab98e37..7b73a6dd1a02 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -92,7 +96,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,14 +107,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,14 +124,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -138,11 +141,11 @@ def extract_data(pipeline_response): 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 @@ -153,5 +156,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py index bd0d9e55d0fb..f310a52a533a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -239,7 +243,7 @@ def list( ) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,17 +254,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -271,14 +274,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -288,11 +291,11 @@ def extract_data(pipeline_response): 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 @@ -304,10 +307,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -324,12 +323,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,22 +343,21 @@ def get( ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,13 +370,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -409,7 +402,6 @@ def put( :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.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -421,7 +413,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -439,11 +431,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -455,7 +446,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -471,18 +462,14 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. + PrivateEndpointConnection type or a IO[bytes] type. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.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 + IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,7 +494,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -516,16 +503,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,13 +524,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -562,12 +544,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,22 +564,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,8 +589,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py index 8038a79cf800..de7e85b96b79 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2020_08_01_preview.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,21 +125,20 @@ def list_by_storage_account( ) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,10 +150,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py index da874e565eaa..baeb858ecda8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -401,7 +400,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -410,16 +409,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -431,13 +429,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -469,7 +463,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -481,7 +474,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -501,11 +494,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -517,7 +509,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -535,17 +527,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -570,7 +558,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -579,16 +567,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,13 +587,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -624,12 +607,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -645,22 +627,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw ) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -672,13 +653,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -698,12 +675,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -719,22 +695,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -744,11 +719,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -774,7 +745,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -787,7 +757,7 @@ def list( ) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -798,19 +768,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -821,14 +790,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -838,11 +807,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 @@ -853,7 +822,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py index 2c9d8d4c2242..766890055fd7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,21 +201,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m ) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,13 +226,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -261,7 +260,6 @@ def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +271,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +291,10 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +306,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum28], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -327,17 +324,14 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties or + IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -362,7 +356,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -371,16 +365,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,13 +385,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -417,12 +406,11 @@ def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,22 +426,21 @@ def get_service_properties( ) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -465,10 +452,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py index f3a654ceab93..1f19454fe810 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.SkuInformation] @@ -98,7 +102,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: ) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,15 +113,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -128,14 +131,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -145,11 +148,11 @@ def extract_data(pipeline_response): 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 @@ -160,5 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py index 586d651ee807..0f057452d61c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -477,7 +477,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -542,7 +542,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -550,18 +549,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -569,26 +567,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -613,22 +607,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -640,22 +633,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -680,7 +669,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -688,16 +677,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -711,13 +699,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -746,14 +730,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -766,7 +742,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -784,18 +760,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -808,7 +776,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -824,20 +792,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. + StorageAccountCreateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCreateParameters - 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. + or IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -872,7 +829,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -882,17 +839,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -907,12 +862,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -928,21 +882,20 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -952,11 +905,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -982,12 +931,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1003,22 +951,21 @@ def get_properties( ) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1030,13 +977,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1069,7 +1012,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1080,7 +1022,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1102,11 +1044,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1117,7 +1058,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1137,18 +1078,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. + StorageAccountUpdateParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountUpdateParameters - 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 + or IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1173,7 +1110,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1181,16 +1118,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1202,20 +1138,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] @@ -1229,7 +1160,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1240,15 +1171,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1259,14 +1189,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1276,11 +1206,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 @@ -1292,8 +1222,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1302,7 +1230,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] @@ -1316,7 +1243,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite ) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1327,16 +1254,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1347,14 +1273,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1364,11 +1290,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 @@ -1380,10 +1306,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1401,12 +1323,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1422,22 +1343,21 @@ def list_keys( ) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,13 +1369,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1483,7 +1399,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1494,7 +1409,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1510,11 +1425,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1525,7 +1439,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1538,18 +1452,16 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters or + IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1574,7 +1486,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1582,16 +1494,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1603,13 +1514,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1636,7 +1543,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1647,7 +1553,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1663,11 +1569,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1678,7 +1583,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1691,17 +1596,14 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters or + IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1726,7 +1628,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1734,16 +1636,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1755,13 +1656,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1787,7 +1684,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1798,7 +1694,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1813,11 +1709,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1828,7 +1723,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1841,17 +1736,14 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters or + IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1876,7 +1768,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1884,16 +1776,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1905,18 +1796,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1932,21 +1819,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1956,11 +1842,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1975,14 +1857,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2011,7 +1885,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -2022,26 +1896,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2066,7 +1936,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2074,16 +1944,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2103,10 +1972,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2131,14 +1996,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -2151,7 +2008,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2166,18 +2023,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -2190,7 +2039,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2203,19 +2052,9 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters or + IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2250,7 +2089,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2262,17 +2101,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2287,12 +2124,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2308,21 +2144,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2332,8 +2167,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py index 4e0020852b3d..6b27ec5041ec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -267,22 +271,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * ) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -294,13 +297,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -317,12 +316,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,22 +336,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * ) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -365,13 +362,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -388,12 +381,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,22 +401,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw ) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,13 +427,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -461,12 +448,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,22 +468,21 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,11 +492,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -524,7 +505,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -537,7 +517,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It ) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -548,17 +528,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -569,14 +548,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -586,11 +565,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 @@ -601,7 +580,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py index b4110f0c8ab7..d8a3129774f8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,21 +201,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m ) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,13 +226,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -261,7 +260,6 @@ def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +271,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum28], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +291,10 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +306,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum28], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -327,17 +324,14 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties or + IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -362,7 +356,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -371,16 +365,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,13 +385,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -417,12 +406,11 @@ def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,22 +426,21 @@ def get_service_properties( ) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -465,10 +452,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py index 1671e9c742e5..12031d9e1fad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us ) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,16 +118,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -134,14 +137,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -151,11 +154,11 @@ def extract_data(pipeline_response): 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 @@ -166,7 +169,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py index 0bdbc41da6fa..e7e0e3cbd4d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json index 07d5fb7e487a..7cadc332e43e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py index 66c86b35a715..0fe4ab7a9b91 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -112,7 +114,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -166,7 +186,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-01-01") - 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 @@ -186,7 +206,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py index 8b46c4e64cf3..f4f55b7f48b7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-01-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py index a17e13ffccda..53cf790d9446 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -169,7 +189,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-01-01") - 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 @@ -189,7 +211,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py index 358709cee4e2..21bf97210bdf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -98,7 +103,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_01_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItem] @@ -110,7 +114,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +125,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -129,12 +133,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -145,14 +148,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -162,11 +165,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 @@ -178,10 +181,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -214,7 +213,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -226,7 +224,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -248,11 +246,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +261,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -284,17 +281,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -317,7 +310,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -326,16 +319,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +347,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -390,7 +378,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -402,7 +389,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -423,11 +410,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -439,7 +425,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -458,17 +444,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +473,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -500,16 +482,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,13 +502,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -547,12 +524,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,22 +542,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -593,13 +568,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -619,12 +590,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,22 +608,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -663,11 +632,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -701,7 +666,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -713,7 +677,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -735,11 +699,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -751,7 +714,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -771,17 +734,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -804,7 +763,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -813,16 +772,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,13 +792,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -873,7 +827,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -885,7 +838,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -906,11 +859,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -922,7 +874,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -941,17 +893,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -974,7 +922,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -983,16 +931,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,13 +951,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1053,7 +996,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1067,7 +1009,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1096,11 +1038,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1114,7 +1055,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1140,17 +1081,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1176,7 +1113,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1187,16 +1124,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1211,13 +1147,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1251,12 +1183,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1270,7 +1201,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1278,16 +1209,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1302,13 +1232,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1344,12 +1270,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1363,7 +1288,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1371,16 +1296,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1395,13 +1319,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1426,12 +1346,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1445,23 +1364,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1476,13 +1394,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1522,7 +1436,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1448,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1562,11 +1475,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1579,7 +1491,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1603,17 +1515,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1639,7 +1547,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1649,16 +1557,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1673,13 +1580,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1712,7 +1615,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1724,7 +1626,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1745,11 +1647,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1761,7 +1662,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1779,18 +1680,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1816,7 +1713,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1825,16 +1722,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1846,10 +1742,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py index 0e4ce195d635..0d3a6570ef86 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +131,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +164,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +194,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +209,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -229,17 +226,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +255,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -271,16 +264,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +353,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +368,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy] @@ -398,7 +379,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +390,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +410,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -447,11 +427,11 @@ async def extract_data(pipeline_response): 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 @@ -463,7 +443,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py index 8eef6d10f4f1..92ebf5702093 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,6 +36,10 @@ build_set_service_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]] @@ -72,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -184,7 +183,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +194,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -216,11 +214,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -232,7 +229,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum30], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -250,17 +247,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +276,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -292,16 +285,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,13 +305,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -338,12 +326,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,22 +344,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,10 +370,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py index 55f83abeb1d3..4b79d70c34e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py index 6ba40a431e95..83e11566a928 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py index 1687b06c2cea..b14be8b68930 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum30], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -215,18 +212,14 @@ async def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py index 0b5673e2ca80..96b5f9185265 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,10 +39,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.ListSharesExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItem] @@ -107,7 +106,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -118,7 +117,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -126,12 +125,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -142,14 +140,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -159,11 +157,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 @@ -175,10 +173,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -214,7 +208,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -226,7 +219,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[Union[str, _models.PutSharesExpand]] = None, *, content_type: str = "application/json", @@ -249,13 +242,12 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -267,7 +259,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[Union[str, _models.PutSharesExpand]] = None, **kwargs: Any ) -> _models.FileShare: @@ -287,20 +279,16 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +311,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +321,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +349,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +380,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +391,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +412,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +427,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +445,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +475,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +484,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +504,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +538,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +556,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +564,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +584,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -647,12 +613,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -666,23 +631,22 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, x_ms_snapshot=x_ms_snapshot, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -692,11 +656,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -728,7 +688,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -740,7 +699,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -760,11 +719,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -776,7 +734,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -793,17 +751,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -826,7 +780,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -835,16 +789,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,8 +807,4 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py index 0f22dada62d3..b2326511f0e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py index f5da4dd85d3b..f946224b2c85 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -172,12 +171,11 @@ async def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,22 +189,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -219,13 +216,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -256,7 +249,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -268,7 +260,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -287,11 +279,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -303,7 +294,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -319,17 +310,14 @@ async def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,7 +340,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -361,16 +349,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,13 +370,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -407,12 +390,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,22 +408,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -452,8 +433,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py index de13b34b6ff7..af976c478c72 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py index fea525d1b6de..eb743576ec5e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.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.storage.v2021_01_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py index d04a9abe69c2..fa1888354890 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_01_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py index 164659f9d303..568bae7a5151 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py index 92ff806eff0c..c4c9410c7179 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum30], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -216,17 +213,13 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py index 098eee4131de..2a5b63c43d71 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py index a0efde0fdb97..3bf028862a44 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,18 +102,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -122,25 +120,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,22 +158,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,22 +184,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +218,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -236,16 +226,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,13 +248,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -294,14 +279,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -314,7 +291,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,18 +309,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -356,7 +325,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -372,19 +341,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -417,7 +376,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -427,17 +386,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -452,12 +409,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,21 +427,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,11 +450,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -525,12 +476,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -544,22 +494,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,13 +520,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -610,7 +555,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -621,7 +565,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -643,11 +587,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -658,7 +601,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -678,17 +621,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +651,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -719,16 +659,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,20 +679,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] @@ -765,7 +699,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,15 +710,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -795,14 +728,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -812,11 +745,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 @@ -828,8 +761,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -840,7 +771,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] @@ -852,7 +782,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,16 +793,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -883,14 +812,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -900,11 +829,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 @@ -916,10 +845,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -937,12 +862,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,22 +880,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -983,13 +906,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1017,7 +936,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1028,7 +946,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1044,11 +962,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1059,7 +976,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1072,18 +989,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1020,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1114,16 +1028,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1135,13 +1048,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1168,7 +1077,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1179,7 +1087,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1195,11 +1103,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1210,7 +1117,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1223,17 +1130,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1256,7 +1159,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1264,16 +1167,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1285,13 +1187,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1317,7 +1215,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1328,7 +1225,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1343,11 +1240,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1358,7 +1254,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1371,17 +1267,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1404,7 +1296,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1412,16 +1304,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1433,18 +1324,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1458,21 +1345,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,11 +1368,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1501,14 +1383,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1535,7 +1409,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1546,26 +1420,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1588,7 +1458,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1596,16 +1466,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1625,10 +1494,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1653,14 +1518,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1673,7 +1530,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1688,18 +1545,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1712,7 +1561,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1725,19 +1574,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -1770,7 +1608,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1782,17 +1620,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1807,12 +1643,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,21 +1661,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1850,8 +1684,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py index a96d37dc58c1..83734d9e3f62 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -148,12 +147,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,22 +165,21 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,13 +191,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -217,12 +210,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,22 +228,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -263,13 +254,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -288,12 +275,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,22 +293,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,11 +317,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -349,7 +330,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -360,7 +340,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,17 +351,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -392,14 +371,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -409,11 +388,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 @@ -424,7 +403,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py index f709b3db5351..78c6d52dee4c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum30], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -216,17 +213,13 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py index a7c7d6e4c23a..0edd3411a409 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py index 97de3678700e..c05583b8f84c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -128,7 +122,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -205,7 +199,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. Ex - - /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 @@ -240,7 +234,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -274,7 +268,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -321,7 +315,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -465,7 +459,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -512,7 +506,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. - 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 filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyFilter @@ -538,7 +532,7 @@ def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs: An class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. - 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 prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] @@ -593,7 +587,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -637,7 +631,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -696,7 +690,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -731,7 +725,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -831,7 +825,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1081,7 +1075,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1178,7 +1172,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1214,7 +1208,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1290,7 +1284,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. Ex - - /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 @@ -1299,22 +1293,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1322,7 +1300,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1406,7 +1384,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1501,7 +1479,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_01_01.models.EncryptionServices @@ -1591,7 +1569,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2019,7 +1997,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2091,7 +2069,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2225,7 +2203,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2430,7 +2408,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2490,7 +2468,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2627,7 +2605,7 @@ def __init__( class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -2716,7 +2694,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -2776,10 +2754,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2818,7 +2796,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -2875,7 +2853,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -2993,7 +2971,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3167,7 +3145,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3331,7 +3309,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3467,7 +3445,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyAction @@ -3506,7 +3484,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -3555,7 +3533,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -3612,7 +3590,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -3829,7 +3807,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -3922,7 +3900,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4021,7 +3999,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -4215,7 +4193,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4300,7 +4278,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. Ex - - /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 @@ -4435,7 +4413,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4503,7 +4481,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -4636,7 +4614,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -4827,7 +4805,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -4897,7 +4875,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5036,10 +5014,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. Ex - - /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 @@ -5084,10 +5062,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -5350,12 +5328,12 @@ def __init__( # pylint: disable=too-many-locals self.enable_nfs_v3 = enable_nfs_v3 -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -5388,7 +5366,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku @@ -5775,7 +5753,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -5976,7 +5954,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6109,7 +6087,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6146,7 +6124,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6186,7 +6164,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -6439,10 +6417,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -6472,7 +6450,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py index df99b9c4a414..d8de14ca8e0b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py @@ -230,7 +230,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py index 965a5096ad85..a9d36d83cf1a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -293,7 +298,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -598,7 +603,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_01_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -609,7 +613,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -620,7 +624,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -628,12 +632,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -644,14 +647,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -661,11 +664,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 @@ -677,10 +680,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -713,7 +712,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -725,7 +723,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -747,11 +745,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -763,7 +760,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -783,17 +780,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +809,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -825,16 +818,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,10 +846,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -889,7 +877,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -901,7 +888,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -922,11 +909,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -938,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -957,17 +943,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -990,7 +972,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -999,16 +981,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,13 +1001,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1046,12 +1023,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1065,22 +1041,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1092,13 +1067,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1118,12 +1089,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1137,22 +1107,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1162,11 +1131,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1200,7 +1165,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1176,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1234,11 +1198,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1250,7 +1213,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1270,17 +1233,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,7 +1262,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1312,16 +1271,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1333,13 +1291,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1372,7 +1326,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1384,7 +1337,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1405,11 +1358,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1421,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1440,17 +1392,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1473,7 +1421,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1482,16 +1430,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1503,13 +1450,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1552,7 +1495,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1508,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1595,11 +1537,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1613,7 +1554,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1639,17 +1580,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1675,7 +1612,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1686,16 +1623,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1710,13 +1646,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1750,12 +1682,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1769,7 +1700,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1777,16 +1708,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1801,13 +1731,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1843,12 +1769,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1862,7 +1787,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1870,16 +1795,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1894,13 +1818,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1925,12 +1845,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1944,23 +1863,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1975,13 +1893,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2021,7 +1935,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2034,7 +1947,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2061,11 +1974,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2078,7 +1990,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2102,17 +2014,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2138,7 +2046,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2148,16 +2056,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2172,13 +2079,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2211,7 +2114,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2223,7 +2125,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2244,11 +2146,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2260,7 +2161,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2278,18 +2179,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2315,7 +2212,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2324,16 +2221,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2345,10 +2241,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py index 50d16226d423..37700c782cac 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +276,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -310,7 +309,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +339,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,7 +354,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -374,17 +371,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +400,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -416,16 +409,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,13 +430,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -467,12 +455,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,22 +473,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,11 +498,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -531,7 +513,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy] @@ -543,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +535,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +555,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -592,11 +572,11 @@ def extract_data(pipeline_response): 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 @@ -608,7 +588,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py index 5b9d5c0320a8..5f9382900792 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -180,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -193,7 +197,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,17 +208,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -225,14 +228,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -242,11 +245,11 @@ def extract_data(pipeline_response): 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 @@ -258,10 +261,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -292,7 +291,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +302,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,11 +322,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +337,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum30], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -358,17 +355,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +384,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -400,16 +393,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +413,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -446,12 +434,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,22 +452,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,10 +478,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py index ac61c718a5a9..43ded3c2f253 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py index 4290fb2dfdc9..d42dbf87a3ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py index eb8bb885f1a6..51e462a9630b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum30], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -324,18 +321,14 @@ def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py index 1d197ef37fa3..3123c5bc3980 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -342,7 +342,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.ListSharesExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -353,7 +352,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +363,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -372,12 +371,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -388,14 +386,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -405,11 +403,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 @@ -421,10 +419,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -460,7 +454,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -472,7 +465,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[Union[str, _models.PutSharesExpand]] = None, *, content_type: str = "application/json", @@ -495,13 +488,12 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -513,7 +505,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[Union[str, _models.PutSharesExpand]] = None, **kwargs: Any ) -> _models.FileShare: @@ -533,20 +525,16 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,7 +557,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -579,16 +567,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,10 +595,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -643,7 +626,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -655,7 +637,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -676,11 +658,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -692,7 +673,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -710,18 +691,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -744,7 +721,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -753,16 +730,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -774,13 +750,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -812,12 +784,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -831,7 +802,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -839,16 +810,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -860,13 +830,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -893,12 +859,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -912,23 +877,22 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, x_ms_snapshot=x_ms_snapshot, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -938,11 +902,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -974,7 +934,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -986,7 +945,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1006,11 +965,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1022,7 +980,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1039,17 +997,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1072,7 +1026,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1081,16 +1035,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1100,8 +1053,4 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py index e5ae047f1a13..36fbcc49df36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py index ab2c7ddd5e29..ae1117ba832a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -311,12 +310,11 @@ def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,22 +328,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,13 +355,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -395,7 +388,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -407,7 +399,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -426,11 +418,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +433,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -458,17 +449,14 @@ def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +479,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -500,16 +488,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,13 +509,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -546,12 +529,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -565,22 +547,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,8 +572,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py index d3a0daa44c98..0e5554708307 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py index cdbbfab21f34..584c4f597bef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_01_01.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.storage.v2021_01_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py index 011fe1abb047..c9bf719d5e97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_01_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py index 6617ed1947c1..c55813666403 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py index 16ced41af9da..2eb6cdf21048 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum30], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -325,17 +322,13 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py index e4f9ca301e8c..f7d361dcb2e9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py index 5ecf1f79ca61..8bc3da6703e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -477,7 +477,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -542,7 +542,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -550,18 +549,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -569,25 +567,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -610,22 +605,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -637,22 +631,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +665,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -683,16 +673,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -706,13 +695,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -741,14 +726,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] @@ -760,7 +737,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -778,18 +755,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] @@ -801,7 +770,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -817,19 +786,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] @@ -861,7 +820,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -871,17 +830,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -896,12 +853,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,21 +871,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -939,11 +894,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -969,12 +920,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,22 +938,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1015,13 +964,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1054,7 +999,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1065,7 +1009,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1087,11 +1031,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1102,7 +1045,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1122,17 +1065,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1155,7 +1095,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1163,16 +1103,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1184,20 +1123,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1208,7 +1142,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1219,15 +1153,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1238,14 +1171,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1255,11 +1188,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 @@ -1271,8 +1204,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1281,7 +1212,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1292,7 +1222,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,16 +1233,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1323,14 +1252,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1340,11 +1269,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 @@ -1356,10 +1285,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1377,12 +1302,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1396,22 +1320,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1423,13 +1346,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1457,7 +1376,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1468,7 +1386,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1484,11 +1402,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1499,7 +1416,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1512,18 +1429,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1546,7 +1460,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1554,16 +1468,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1575,13 +1488,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1608,7 +1517,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1619,7 +1527,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1635,11 +1543,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1650,7 +1557,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1663,17 +1570,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1696,7 +1599,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1704,16 +1607,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1725,13 +1627,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1757,7 +1655,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1768,7 +1665,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1783,11 +1680,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1798,7 +1694,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1811,17 +1707,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1844,7 +1736,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1852,16 +1744,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1873,18 +1764,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1898,21 +1785,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1922,11 +1808,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1941,14 +1823,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1975,7 +1849,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1986,26 +1860,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2028,7 +1898,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2036,16 +1906,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2065,10 +1934,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2093,14 +1958,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] @@ -2112,7 +1969,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2127,18 +1984,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] @@ -2150,7 +1999,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2163,19 +2012,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] @@ -2207,7 +2045,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2219,17 +2057,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2244,12 +2080,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2263,21 +2098,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2287,8 +2121,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py index 0b9201e14c18..958b2edaa6e7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,22 +269,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,13 +295,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -315,12 +314,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,22 +332,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,13 +358,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -384,12 +377,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,22 +395,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,13 +421,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -455,12 +442,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,22 +460,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,11 +484,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -516,7 +497,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -527,7 +507,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,17 +518,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +538,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -576,11 +555,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 @@ -591,7 +570,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py index eb927e617c2f..978d7df9771e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum30], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum30], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -325,17 +322,13 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py index 2ceb46f3a4d8..7b96f58461df 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py index b7190b635bbc..81bea65fe510 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-02-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json index 4e9824eaca2e..6cb872939b5a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py index e4eb2325ae46..dac901a8114c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -112,7 +114,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -166,7 +186,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-02-01") - 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 @@ -186,7 +206,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py index bf49f096ebf9..d3591c932148 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-02-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py index 00b5e35e31a2..f1171f15d2f8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -169,7 +189,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-02-01") - 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 @@ -189,7 +211,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py index b117b92d2fc2..56beba94f9e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -45,6 +46,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]] @@ -98,7 +103,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_02_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItem] @@ -110,7 +114,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +125,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -129,12 +133,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -145,14 +148,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -162,11 +165,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 @@ -178,10 +181,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -214,7 +213,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -226,7 +224,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -248,11 +246,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +261,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -284,17 +281,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -317,7 +310,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -326,16 +319,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +347,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -390,7 +378,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -402,7 +389,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -423,11 +410,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -439,7 +425,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -458,17 +444,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +473,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -500,16 +482,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,13 +502,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -547,12 +524,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,22 +542,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -593,13 +568,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -619,12 +590,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,22 +608,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -663,11 +632,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -701,7 +666,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -713,7 +677,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -735,11 +699,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -751,7 +714,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -771,17 +734,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -804,7 +763,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -813,16 +772,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,13 +792,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -873,7 +827,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -885,7 +838,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -906,11 +859,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -922,7 +874,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -941,17 +893,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -974,7 +922,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -983,16 +931,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,13 +951,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1053,7 +996,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1067,7 +1009,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1096,11 +1038,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1114,7 +1055,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1140,17 +1081,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1176,7 +1113,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1187,16 +1124,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1211,13 +1147,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1251,12 +1183,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1270,7 +1201,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1278,16 +1209,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1302,13 +1232,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1344,12 +1270,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1363,7 +1288,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1371,16 +1296,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1395,13 +1319,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1426,12 +1346,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1445,23 +1364,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1476,13 +1394,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1522,7 +1436,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1448,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1562,11 +1475,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1579,7 +1491,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1603,17 +1515,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1639,7 +1547,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1649,16 +1557,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1673,13 +1580,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1712,7 +1615,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1724,7 +1626,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1745,11 +1647,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1761,7 +1662,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1779,18 +1680,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1816,7 +1713,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1825,16 +1722,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1846,10 +1742,6 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py index 60fb1fcfad0f..c616681ecf49 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +131,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +164,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +194,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +209,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -229,17 +226,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +255,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -271,16 +264,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +353,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +368,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy] @@ -398,7 +379,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +390,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +410,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -447,11 +427,11 @@ async def extract_data(pipeline_response): 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 @@ -463,7 +443,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py index a05b71cc48f0..7eb0bf76f502 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,6 +36,10 @@ build_set_service_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]] @@ -72,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -184,7 +183,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +194,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -216,11 +214,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -232,7 +229,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum31], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -250,17 +247,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +276,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -292,16 +285,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,13 +305,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -338,12 +326,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,22 +344,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,10 +370,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py index f04f4991a3a4..db12eda9dffe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py index d65162fb2508..77e97c3c6f7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py index 476a2b8c4c34..157848350567 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum31], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -215,18 +212,14 @@ async def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py index 0827fc214ca0..4e7c1bb00549 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,10 +39,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.ListSharesExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItem] @@ -107,7 +106,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -118,7 +117,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -126,12 +125,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -142,14 +140,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -159,11 +157,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 @@ -175,10 +173,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -214,7 +208,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -226,7 +219,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[Union[str, _models.PutSharesExpand]] = None, *, content_type: str = "application/json", @@ -249,13 +242,12 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -267,7 +259,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[Union[str, _models.PutSharesExpand]] = None, **kwargs: Any ) -> _models.FileShare: @@ -287,20 +279,16 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +311,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +321,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +349,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +380,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +391,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +412,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +427,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +445,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +475,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +484,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +504,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +538,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +556,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +564,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +584,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -647,12 +613,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -666,23 +631,22 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, x_ms_snapshot=x_ms_snapshot, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -692,11 +656,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -728,7 +688,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -740,7 +699,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -760,11 +719,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -776,7 +734,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -793,17 +751,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -826,7 +780,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -835,16 +789,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,8 +807,4 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py index baa585356b31..416b1abc4c15 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py index 52a075ea65a2..23f092418ebf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -172,12 +171,11 @@ async def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,22 +189,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -219,13 +216,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -256,7 +249,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -268,7 +260,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -287,11 +279,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -303,7 +294,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -319,17 +310,14 @@ async def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,7 +340,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -361,16 +349,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,13 +370,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -407,12 +390,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,22 +408,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -452,8 +433,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py index 211595d824bd..30c64363bc2d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py index 6595b0dcb933..dbd72b159da8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.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.storage.v2021_02_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py index e52feb8f308a..7763354bb966 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_02_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py index 15db2c6708a5..4aab31d1795c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py index 5b9d81365013..2d7d416eea7b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum31], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -216,17 +213,13 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py index d18af759143e..9b9056c0b91a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py index 68ec508d9a43..c9f73b49e41f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,18 +102,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -122,25 +120,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,22 +158,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,22 +184,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +218,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -236,16 +226,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,13 +248,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -294,14 +279,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -314,7 +291,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,18 +309,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -356,7 +325,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -372,19 +341,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -417,7 +376,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -427,17 +386,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -452,12 +409,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,21 +427,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,11 +450,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -525,12 +476,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -544,22 +494,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,13 +520,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -610,7 +555,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -621,7 +565,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -643,11 +587,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -658,7 +601,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -678,17 +621,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +651,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -719,16 +659,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,20 +679,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] @@ -765,7 +699,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,15 +710,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -795,14 +728,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -812,11 +745,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 @@ -828,8 +761,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -840,7 +771,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] @@ -852,7 +782,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,16 +793,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -883,14 +812,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -900,11 +829,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 @@ -916,10 +845,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -937,12 +862,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,22 +880,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -983,13 +906,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1017,7 +936,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1028,7 +946,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1044,11 +962,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1059,7 +976,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1072,18 +989,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1020,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1114,16 +1028,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1135,13 +1048,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1168,7 +1077,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1179,7 +1087,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1195,11 +1103,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1210,7 +1117,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1223,17 +1130,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1256,7 +1159,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1264,16 +1167,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1285,13 +1187,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1317,7 +1215,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1328,7 +1225,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1343,11 +1240,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1358,7 +1254,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1371,17 +1267,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1404,7 +1296,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1412,16 +1304,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1433,18 +1324,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1458,21 +1345,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,11 +1368,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1501,14 +1383,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1535,7 +1409,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1546,26 +1420,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1588,7 +1458,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1596,16 +1466,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1625,10 +1494,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1653,14 +1518,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1673,7 +1530,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1688,18 +1545,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1712,7 +1561,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1725,19 +1574,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -1770,7 +1608,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1782,17 +1620,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1807,12 +1643,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,21 +1661,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1850,8 +1684,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py index 818592053bc2..711d65a7ec89 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -148,12 +147,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,22 +165,21 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,13 +191,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -217,12 +210,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,22 +228,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -263,13 +254,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -288,12 +275,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,22 +293,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,11 +317,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -349,7 +330,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -360,7 +340,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,17 +351,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -392,14 +371,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -409,11 +388,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 @@ -424,7 +403,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py index 74c3a23606bc..9bfce4a6109c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -150,7 +149,6 @@ async def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -162,7 +160,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -182,11 +180,10 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +195,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum31], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -216,17 +213,13 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -258,16 +251,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +271,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -304,12 +292,11 @@ async def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,22 +310,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +336,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py index 5e5bb244d769..ffd5e640defc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py index a8c22896020a..30a95af8e0ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -26,7 +20,7 @@ class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -128,7 +122,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -205,7 +199,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. Ex - - /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 @@ -240,7 +234,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -274,7 +268,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -321,7 +315,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -465,7 +459,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -512,7 +506,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. - 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 filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyFilter @@ -538,7 +532,7 @@ def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs: An class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. - 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 prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] @@ -593,7 +587,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -637,7 +631,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -696,7 +690,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -731,7 +725,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -831,7 +825,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1081,7 +1075,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1178,7 +1172,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1214,7 +1208,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1290,7 +1284,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. Ex - - /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 @@ -1299,22 +1293,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1322,7 +1300,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1406,7 +1384,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1501,7 +1479,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_02_01.models.EncryptionServices @@ -1591,7 +1569,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2019,7 +1997,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2091,7 +2069,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2225,7 +2203,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2430,7 +2408,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2490,7 +2468,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2627,7 +2605,7 @@ def __init__( class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -2689,7 +2667,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -2770,7 +2748,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -2830,10 +2808,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2872,7 +2850,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -2929,7 +2907,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3047,7 +3025,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3221,7 +3199,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3385,7 +3363,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3521,7 +3499,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyAction @@ -3560,7 +3538,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -3609,7 +3587,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -3666,7 +3644,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -3883,7 +3861,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -3976,7 +3954,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4075,7 +4053,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -4269,7 +4247,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4354,7 +4332,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. Ex - - /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 @@ -4489,7 +4467,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4557,7 +4535,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -4690,7 +4668,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -4729,7 +4707,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -4920,7 +4898,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -4990,7 +4968,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5129,10 +5107,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. Ex - - /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 @@ -5177,10 +5155,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -5458,12 +5436,12 @@ def __init__( # pylint: disable=too-many-locals self.enable_nfs_v3 = enable_nfs_v3 -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -5496,7 +5474,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku @@ -5902,7 +5880,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -6117,7 +6095,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6250,7 +6228,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6287,7 +6265,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6327,7 +6305,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -6580,10 +6558,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -6613,7 +6591,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py index b8d266217924..c8f6f588af5e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py @@ -236,7 +236,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py index 891eaa2bd459..4fea134b9ee6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -293,7 +298,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -598,7 +603,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_02_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -609,7 +613,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -620,7 +624,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -628,12 +632,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -644,14 +647,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -661,11 +664,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 @@ -677,10 +680,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -713,7 +712,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -725,7 +723,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -747,11 +745,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -763,7 +760,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -783,17 +780,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -816,7 +809,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -825,16 +818,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,10 +846,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -889,7 +877,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -901,7 +888,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -922,11 +909,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -938,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -957,17 +943,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -990,7 +972,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -999,16 +981,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,13 +1001,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1046,12 +1023,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1065,22 +1041,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1092,13 +1067,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1118,12 +1089,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1137,22 +1107,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1162,11 +1131,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1200,7 +1165,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1176,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1234,11 +1198,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1250,7 +1213,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1270,17 +1233,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,7 +1262,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1312,16 +1271,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1333,13 +1291,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1372,7 +1326,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1384,7 +1337,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1405,11 +1358,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1421,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1440,17 +1392,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1473,7 +1421,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1482,16 +1430,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1503,13 +1450,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1552,7 +1495,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1508,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1595,11 +1537,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1613,7 +1554,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1639,17 +1580,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1675,7 +1612,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1686,16 +1623,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1710,13 +1646,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1750,12 +1682,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1769,7 +1700,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1777,16 +1708,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1801,13 +1731,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1843,12 +1769,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1862,7 +1787,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1870,16 +1795,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1894,13 +1818,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1925,12 +1845,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1944,23 +1863,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1975,13 +1893,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2021,7 +1935,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2034,7 +1947,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2061,11 +1974,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2078,7 +1990,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2102,17 +2014,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2138,7 +2046,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2148,16 +2056,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2172,13 +2079,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2211,7 +2114,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2223,7 +2125,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2244,11 +2146,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2260,7 +2161,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2278,18 +2179,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2315,7 +2212,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2324,16 +2221,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2345,10 +2241,6 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py index 0aa318b14484..033ac8fd81c5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +276,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -310,7 +309,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +339,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,7 +354,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -374,17 +371,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +400,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -416,16 +409,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,13 +430,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -467,12 +455,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,22 +473,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,11 +498,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -531,7 +513,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy] @@ -543,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +535,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +555,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -592,11 +572,11 @@ def extract_data(pipeline_response): 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 @@ -608,7 +588,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py index 00ed213d9cfa..df23d1b3ea8d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -180,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -193,7 +197,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,17 +208,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -225,14 +228,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -242,11 +245,11 @@ def extract_data(pipeline_response): 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 @@ -258,10 +261,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -292,7 +291,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +302,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,11 +322,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +337,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum31], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -358,17 +355,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +384,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -400,16 +393,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +413,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -446,12 +434,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,22 +452,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,10 +478,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py index 674750c16e38..2ca2bdd117ad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py index 29f87bbf16da..bf0f1063eef3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py index f6c2ce0e1d86..af65055c029b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum31], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -324,18 +321,14 @@ def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py index 5dd42c1e831a..4319a45c1ee3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -342,7 +342,6 @@ def list( :param expand: Optional, used to expand the properties within share's properties. Known values are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.ListSharesExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -353,7 +352,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +363,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -372,12 +371,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -388,14 +386,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -405,11 +403,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 @@ -421,10 +419,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -460,7 +454,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -472,7 +465,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[Union[str, _models.PutSharesExpand]] = None, *, content_type: str = "application/json", @@ -495,13 +488,12 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -513,7 +505,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[Union[str, _models.PutSharesExpand]] = None, **kwargs: Any ) -> _models.FileShare: @@ -533,20 +525,16 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO[bytes] :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,7 +557,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -579,16 +567,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,10 +595,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -643,7 +626,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -655,7 +637,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -676,11 +658,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -692,7 +673,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -710,18 +691,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -744,7 +721,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -753,16 +730,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -774,13 +750,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -812,12 +784,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -831,7 +802,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -839,16 +810,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -860,13 +830,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -893,12 +859,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -912,23 +877,22 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, x_ms_snapshot=x_ms_snapshot, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -938,11 +902,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -974,7 +934,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -986,7 +945,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1006,11 +965,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1022,7 +980,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1039,17 +997,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1072,7 +1026,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1081,16 +1035,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1100,8 +1053,4 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py index 4e9a1d0754c4..b5bde8ded4de 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py index 7b0dc37e55a6..b3cf539bbbe1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -311,12 +310,11 @@ def get( :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,22 +328,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,13 +355,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -395,7 +388,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -407,7 +399,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -426,11 +418,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +433,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -458,17 +449,14 @@ def create_or_update( policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +479,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -500,16 +488,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,13 +509,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -546,12 +529,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param object_replication_policy_id: The ID of object replication policy or 'default' if the policy ID is unknown. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -565,22 +547,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,8 +572,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py index e68a675e946d..ad0e815861c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py index 64941a235d9d..bf0eecf41c46 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_02_01.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.storage.v2021_02_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py index 95a690b92ab7..c994da87fe6d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_02_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py index 29e73414cac4..af9cbd501961 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py index a800e29fb605..8a599f5fe375 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum31], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -325,17 +322,13 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py index ae7e9d3b12c3..bb75cce90afb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py index 98fd0ca67758..8e0493052e4b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -477,7 +477,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -542,7 +542,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -550,18 +549,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -569,25 +567,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -610,22 +605,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -637,22 +631,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +665,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -683,16 +673,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -706,13 +695,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -741,14 +726,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] @@ -760,7 +737,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -778,18 +755,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] @@ -801,7 +770,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -817,19 +786,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] @@ -861,7 +820,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -871,17 +830,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -896,12 +853,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,21 +871,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -939,11 +894,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -969,12 +920,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,22 +938,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1015,13 +964,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1054,7 +999,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1065,7 +1009,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1087,11 +1031,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1102,7 +1045,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1122,17 +1065,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1155,7 +1095,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1163,16 +1103,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1184,20 +1123,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1208,7 +1142,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1219,15 +1153,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1238,14 +1171,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1255,11 +1188,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 @@ -1271,8 +1204,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1281,7 +1212,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1292,7 +1222,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,16 +1233,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1323,14 +1252,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1340,11 +1269,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 @@ -1356,10 +1285,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1377,12 +1302,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1396,22 +1320,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1423,13 +1346,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1457,7 +1376,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1468,7 +1386,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1484,11 +1402,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1499,7 +1416,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1512,18 +1429,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1546,7 +1460,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1554,16 +1468,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1575,13 +1488,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1608,7 +1517,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1619,7 +1527,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1635,11 +1543,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1650,7 +1557,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1663,17 +1570,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1696,7 +1599,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1704,16 +1607,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1725,13 +1627,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1757,7 +1655,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1768,7 +1665,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1783,11 +1680,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1798,7 +1694,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1811,17 +1707,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1844,7 +1736,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1852,16 +1744,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1873,18 +1764,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1898,21 +1785,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1922,11 +1808,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1941,14 +1823,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1975,7 +1849,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1986,26 +1860,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2028,7 +1898,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2036,16 +1906,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2065,10 +1934,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2093,14 +1958,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] @@ -2112,7 +1969,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2127,18 +1984,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] @@ -2150,7 +1999,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2163,19 +2012,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] @@ -2207,7 +2045,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2219,17 +2057,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2244,12 +2080,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2263,21 +2098,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2287,8 +2121,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py index d9aeb5183ed2..4188a39cea35 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,22 +269,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,13 +295,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -315,12 +314,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,22 +332,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,13 +358,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -384,12 +377,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,22 +395,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,13 +421,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -455,12 +442,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,22 +460,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,11 +484,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -516,7 +497,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -527,7 +507,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,17 +518,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +538,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -576,11 +555,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 @@ -591,7 +570,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py index f3a7a20db5af..6e4f0daccbe9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -259,7 +258,6 @@ def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +269,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum31], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +289,10 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +304,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum31], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -325,17 +322,13 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +351,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -367,16 +360,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +380,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -413,12 +401,11 @@ def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +419,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,10 +445,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py index b54df2be5a7d..48091a67c8e3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-02-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py index 76521c75699a..03ebdfc441f4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json index 5119fc236b7f..7320234d7316 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py index f168e3e7a3d3..79386dd910fd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -112,7 +114,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -166,7 +186,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-04-01") - 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 @@ -186,7 +206,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py index f0120513b2a7..c5765ad05aae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py index 615eb51dd13b..9b925d1c4783 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -169,7 +189,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-04-01") - 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 @@ -189,7 +211,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py index c9282944dfba..9c56fa59611e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -48,6 +49,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]] @@ -101,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_04_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItem] @@ -113,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -132,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -148,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -165,11 +168,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 @@ -181,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -217,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -229,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -251,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -267,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -287,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -320,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -329,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -393,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -405,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -426,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -461,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -503,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -524,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -550,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -622,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -641,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -704,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -716,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -738,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -754,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -774,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -807,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -816,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -837,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -876,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -888,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -909,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -925,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -944,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -977,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -986,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1007,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1056,7 +999,6 @@ async def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1070,7 +1012,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1099,11 +1041,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1117,7 +1058,7 @@ async def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1143,17 +1084,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1179,7 +1116,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1190,16 +1127,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1214,13 +1150,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1254,12 +1186,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1273,7 +1204,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1281,16 +1212,15 @@ async def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1305,13 +1235,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1347,12 +1273,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1366,7 +1291,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1374,16 +1299,15 @@ async def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1398,13 +1322,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1429,12 +1349,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1448,23 +1367,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1479,13 +1397,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1525,7 +1439,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1538,7 +1451,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1565,11 +1478,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1582,7 +1494,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1606,17 +1518,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1642,7 +1550,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1652,16 +1560,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1676,13 +1583,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1715,7 +1618,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1727,7 +1629,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1748,11 +1650,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1764,7 +1665,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1782,18 +1683,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1819,7 +1716,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1828,16 +1725,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1849,18 +1745,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1874,22 +1766,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1899,11 +1790,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1926,14 +1813,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1961,7 +1840,7 @@ async def begin_object_level_worm( 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( @@ -1972,14 +1851,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py index 75dd5d086d0a..0ea553b42740 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +131,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +164,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +194,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +209,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -229,17 +226,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +255,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -271,16 +264,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +353,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +368,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy] @@ -398,7 +379,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +390,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +410,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -447,11 +427,11 @@ async def extract_data(pipeline_response): 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 @@ -463,7 +443,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py index 156d97d51eb2..50363f77bf92 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,6 +36,10 @@ build_set_service_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]] @@ -72,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -184,7 +183,6 @@ async def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +194,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -216,11 +214,10 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -232,7 +229,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum35], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -250,17 +247,13 @@ async def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +276,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -292,16 +285,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,13 +305,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -338,12 +326,11 @@ async def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,22 +344,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,10 +370,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py index a0af4470ae6e..c2114db4e0d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py index bde659f4cfd3..11a48251eb0b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py index 6fe04050fea6..2f7e34171803 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,13 +116,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,7 +150,6 @@ async def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -163,7 +161,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,11 +181,10 @@ async def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -199,7 +196,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum35], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -216,18 +213,14 @@ async def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,7 +243,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -259,16 +252,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -281,13 +273,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -306,12 +294,11 @@ async def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,22 +312,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -353,10 +339,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py index 2866955ff3b7..72f6609eb22a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -173,10 +176,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -213,7 +212,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -225,7 +223,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -248,14 +246,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -267,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -287,21 +284,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,7 +317,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -334,16 +327,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,10 +356,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -399,7 +387,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +398,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +419,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +434,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -466,18 +452,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +482,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -509,16 +491,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +512,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -569,12 +546,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,7 +564,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -596,16 +572,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +593,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -660,12 +631,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -679,7 +649,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -687,16 +657,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -707,11 +676,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -743,7 +708,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -755,7 +719,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -775,11 +739,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -791,7 +754,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -808,17 +771,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -841,7 +800,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -850,16 +809,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -870,11 +828,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -911,7 +865,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -924,7 +877,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -948,11 +901,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -965,7 +917,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -986,18 +938,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1023,7 +971,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1033,16 +981,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1058,10 +1005,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py index b88b984c76e5..004fd58c4283 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py index 423507e12fb9..d26abe662500 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py index a92bdb5c2d79..5e24779407b4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py index b9de8dd302c4..0aa67b410e62 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.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.storage.v2021_04_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py index 9fbc052073d2..581739b525b8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_04_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py index 12ec5865fad3..c65f7b356274 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +219,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -259,7 +253,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +264,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +284,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +299,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -325,17 +317,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +346,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -367,16 +355,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,13 +376,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -415,12 +398,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +416,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,13 +443,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -488,12 +465,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,22 +483,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -533,11 +508,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -563,7 +534,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueue] @@ -575,7 +545,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,19 +556,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -609,14 +578,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -626,11 +595,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 @@ -642,7 +611,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py index caf12c5f11c4..fbdd93a3acba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,13 +116,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,7 +150,6 @@ async def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -163,7 +161,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,11 +181,10 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -199,7 +196,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum35], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -217,17 +214,13 @@ async def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,7 +243,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -259,16 +252,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -281,13 +273,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -306,12 +294,11 @@ async def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,22 +312,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -353,10 +339,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py index ae8056064991..4dc0cc326178 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py index 59702e43c19f..3e14cf8091b8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +95,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,18 +102,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -122,25 +120,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,22 +158,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,22 +184,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +218,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -236,16 +226,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -259,13 +248,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -294,14 +279,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -314,7 +291,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,18 +309,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -356,7 +325,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -372,19 +341,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -417,7 +376,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -427,17 +386,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -452,12 +409,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,21 +427,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,11 +450,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -525,12 +476,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_04_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -544,22 +494,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,13 +520,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -610,7 +555,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -621,7 +565,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -643,11 +587,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -658,7 +601,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -678,17 +621,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +651,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -719,16 +659,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,20 +679,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] @@ -765,7 +699,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,15 +710,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -795,14 +728,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -812,11 +745,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 @@ -828,8 +761,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -840,7 +771,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] @@ -852,7 +782,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,16 +793,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -883,14 +812,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -900,11 +829,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 @@ -916,10 +845,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -937,12 +862,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,22 +880,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -983,13 +906,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1017,7 +936,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1028,7 +946,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1044,11 +962,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1059,7 +976,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1072,18 +989,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,7 +1020,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1114,16 +1028,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1135,13 +1048,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1168,7 +1077,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1179,7 +1087,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1195,11 +1103,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1210,7 +1117,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1223,17 +1130,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1256,7 +1159,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1264,16 +1167,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1285,13 +1187,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1317,7 +1215,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1328,7 +1225,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1343,11 +1240,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1358,7 +1254,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1371,17 +1267,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1404,7 +1296,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1412,16 +1304,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1433,18 +1324,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1458,21 +1345,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,11 +1368,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1501,14 +1383,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1535,7 +1409,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1546,26 +1420,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1588,7 +1458,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1596,16 +1466,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1625,10 +1494,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1653,14 +1518,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1673,7 +1530,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1688,18 +1545,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1712,7 +1561,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1725,19 +1574,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -1770,7 +1608,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1782,17 +1620,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -1807,12 +1643,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,21 +1661,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1850,8 +1684,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py index 01ebdf6eb91c..8c70ea53523c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,13 +127,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -149,12 +148,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,22 +166,21 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,13 +193,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -219,12 +212,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,22 +230,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,13 +257,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -291,12 +278,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,22 +296,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -336,11 +321,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -353,7 +334,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +344,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,17 +355,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -396,14 +375,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -413,11 +392,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 @@ -429,7 +408,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py index 89cf01518907..049f361e72da 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ build_set_service_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 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,13 +116,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,7 +150,6 @@ async def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -163,7 +161,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,11 +181,10 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -199,7 +196,7 @@ async def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum35], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -217,17 +214,13 @@ async def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,7 +243,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -259,16 +252,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -281,13 +273,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -306,12 +294,11 @@ async def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,22 +312,21 @@ async def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -353,10 +339,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py index cf9f78139cd6..d0add84a4fef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py index bbd98a73afd1..3a8dd1e4ad41 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -65,7 +59,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -167,7 +161,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -244,7 +238,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. Ex - - /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 @@ -279,7 +273,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -313,7 +307,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -375,7 +369,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -535,7 +529,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -582,7 +576,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyFilter @@ -731,7 +725,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -790,7 +784,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -839,7 +833,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -874,7 +868,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -974,7 +968,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1296,7 +1290,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1393,7 +1387,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1429,7 +1423,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1505,7 +1499,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. Ex - - /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 @@ -1514,22 +1508,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1537,7 +1515,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1621,7 +1599,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1716,7 +1694,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_04_01.models.EncryptionServices @@ -1806,7 +1784,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2234,7 +2212,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2306,7 +2284,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2464,7 +2442,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2693,7 +2671,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2753,7 +2731,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2928,7 +2906,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -2990,7 +2968,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3071,7 +3049,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3131,10 +3109,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3173,7 +3151,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3228,10 +3206,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3270,7 +3248,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3327,7 +3305,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3445,7 +3423,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3635,7 +3613,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3799,7 +3777,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3935,7 +3913,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyAction @@ -3974,7 +3952,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4023,7 +4001,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4080,7 +4058,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4297,7 +4275,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -4390,7 +4368,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4493,7 +4471,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -4687,7 +4665,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4772,7 +4750,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. Ex - - /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 @@ -4907,7 +4885,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4975,7 +4953,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5108,7 +5086,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5147,7 +5125,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -5370,7 +5348,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5440,7 +5418,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5579,10 +5557,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. Ex - - /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 @@ -5627,10 +5605,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -5917,12 +5895,12 @@ def __init__( # pylint: disable=too-many-locals self.allow_cross_tenant_replication = allow_cross_tenant_replication -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -5955,7 +5933,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku @@ -6370,7 +6348,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -6594,7 +6572,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6727,7 +6705,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6764,7 +6742,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -6804,7 +6782,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -7057,10 +7035,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -7090,7 +7068,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py index 094c9006d1d1..309f0b395d32 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py @@ -253,7 +253,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -273,7 +272,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py index 1805f0850565..9c68296ffd8d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_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, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ 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]] @@ -295,7 +300,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -634,7 +639,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_04_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -645,7 +649,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,7 +660,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -664,12 +668,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +683,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -697,11 +700,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 @@ -713,10 +716,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -749,7 +748,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -761,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -783,11 +781,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -799,7 +796,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -819,17 +816,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -852,7 +845,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -861,16 +854,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -890,10 +882,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -925,7 +913,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -937,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -958,11 +945,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -974,7 +960,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -993,17 +979,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1026,7 +1008,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1035,16 +1017,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1056,13 +1037,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1082,12 +1059,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1101,22 +1077,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1128,13 +1103,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1154,12 +1125,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1173,22 +1143,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1198,11 +1167,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1236,7 +1201,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1248,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1270,11 +1234,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1286,7 +1249,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1306,17 +1269,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1339,7 +1298,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1348,16 +1307,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1369,13 +1327,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1408,7 +1362,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1420,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1441,11 +1394,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1457,7 +1409,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1476,17 +1428,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1509,7 +1457,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1518,16 +1466,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1539,13 +1486,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1588,7 +1531,6 @@ def create_or_update_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1602,7 +1544,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1631,11 +1573,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1649,7 +1590,7 @@ def create_or_update_immutability_policy( container_name: str, immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1675,17 +1616,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1711,7 +1648,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1722,16 +1659,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1746,13 +1682,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1786,12 +1718,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1805,7 +1736,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1813,16 +1744,15 @@ def get_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1837,13 +1767,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1879,12 +1805,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1898,7 +1823,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1906,16 +1831,15 @@ def delete_immutability_policy( subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1930,13 +1854,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1961,12 +1881,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1980,23 +1899,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2011,13 +1929,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2057,7 +1971,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2070,7 +1983,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2097,11 +2010,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2114,7 +2026,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2138,17 +2050,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2174,7 +2082,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2184,16 +2092,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2208,13 +2115,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2247,7 +2150,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2259,7 +2161,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2280,11 +2182,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2296,7 +2197,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2314,18 +2215,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2351,7 +2248,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2360,16 +2257,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2381,18 +2277,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2406,22 +2298,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2431,11 +2322,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2458,14 +2345,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2493,7 +2372,7 @@ def begin_object_level_worm( 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( @@ -2504,14 +2383,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py index ca57a6961d28..fe527ca86bfd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +276,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -310,7 +309,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +339,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,7 +354,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -374,17 +371,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +400,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -416,16 +409,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,13 +430,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -467,12 +455,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,22 +473,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,11 +498,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -531,7 +513,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy] @@ -543,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +535,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +555,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -592,11 +572,11 @@ def extract_data(pipeline_response): 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 @@ -608,7 +588,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py index df035c442511..20f4c8b363f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -180,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -193,7 +197,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,17 +208,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -225,14 +228,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -242,11 +245,11 @@ def extract_data(pipeline_response): 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 @@ -258,10 +261,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -292,7 +291,6 @@ def set_service_properties( :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: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +302,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -324,11 +322,10 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +337,7 @@ def set_service_properties( resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum35], - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -358,17 +355,13 @@ def set_service_properties( :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties 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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +384,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, @@ -400,16 +393,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +413,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -446,12 +434,11 @@ def get_service_properties( :param blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. "default" Required. :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,22 +452,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,10 +478,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py index db79b43e787d..605a7d468180 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py index 06cc003cc34e..f3db7f7ee940 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py index 0a55a75f588c..dd7a2825356c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,13 +225,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -260,7 +259,6 @@ def set_service_properties( :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: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +270,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,11 +290,10 @@ def set_service_properties( :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +305,7 @@ def set_service_properties( resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum35], - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -325,18 +322,14 @@ def set_service_properties( File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties 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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +352,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, @@ -368,16 +361,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +382,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -415,12 +403,11 @@ def get_service_properties( :param file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". "default" Required. :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +421,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,10 +448,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py index 474988855f7c..99420fb844a4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -386,7 +391,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +401,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,7 +412,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -416,12 +420,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -432,14 +435,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -449,11 +452,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 @@ -466,10 +469,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -506,7 +505,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -518,7 +516,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -541,14 +539,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -560,7 +557,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -580,21 +577,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -617,7 +610,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -627,16 +620,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -657,10 +649,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -692,7 +680,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -704,7 +691,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -725,11 +712,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -741,7 +727,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -759,18 +745,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -793,7 +775,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -802,16 +784,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -824,13 +805,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -862,12 +839,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -881,7 +857,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -889,16 +865,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -911,13 +886,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -953,12 +924,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -972,7 +942,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -980,16 +950,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1000,11 +969,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1036,7 +1001,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1048,7 +1012,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1068,11 +1032,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1084,7 +1047,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1101,17 +1064,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1134,7 +1093,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1143,16 +1102,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1163,11 +1121,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1204,7 +1158,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1217,7 +1170,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1241,11 +1194,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1258,7 +1210,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1279,18 +1231,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1316,7 +1264,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1326,16 +1274,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1351,10 +1298,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py index f32caeb08e80..df046ede1190 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py index c5eb124af7e4..311327d9fd46 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +330,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,13 +357,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +424,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +439,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -466,17 +457,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +487,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -508,16 +496,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,13 +517,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -556,12 +539,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +557,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,8 +582,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py index a0afebb2e1a1..38500019f335 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py index 39f893c6e037..81eac8d8e1d8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_04_01.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.storage.v2021_04_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py index 42b780509fdd..7d0ba74d13ea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_04_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py index 7d8b38b370ca..d0329c469f58 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,13 +428,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -468,7 +462,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -480,7 +473,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -500,11 +493,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -516,7 +508,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -534,17 +526,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,7 +555,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -576,16 +564,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -598,13 +585,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -622,12 +605,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -641,22 +623,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -669,13 +650,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -695,12 +672,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -714,22 +690,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,11 +715,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -770,7 +741,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -781,7 +751,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -792,19 +762,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -815,14 +784,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -832,11 +801,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 @@ -848,7 +817,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py index 2a0d78b97f13..40e2d5165bc1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,13 +225,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -260,7 +259,6 @@ def set_service_properties( :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: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +270,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,11 +290,10 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +305,7 @@ def set_service_properties( resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum35], - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -326,17 +323,13 @@ def set_service_properties( :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties 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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +352,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, @@ -368,16 +361,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +382,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -415,12 +403,11 @@ def get_service_properties( :param queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. "default" Required. :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +421,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,10 +448,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py index cea8ed284a4c..d1a8e845a31a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py index 807ef12382cd..8e61009e7a15 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -477,7 +477,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -542,7 +542,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -550,18 +549,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -569,25 +567,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -610,22 +605,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -637,22 +631,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +665,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -683,16 +673,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -706,13 +695,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -741,14 +726,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] @@ -760,7 +737,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -778,18 +755,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] @@ -801,7 +770,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -817,19 +786,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] @@ -861,7 +820,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -871,17 +830,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -896,12 +853,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,21 +871,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -939,11 +894,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -969,12 +920,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_04_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,22 +938,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1015,13 +964,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1054,7 +999,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1065,7 +1009,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1087,11 +1031,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1102,7 +1045,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1122,17 +1065,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1155,7 +1095,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1163,16 +1103,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1184,20 +1123,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1208,7 +1142,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1219,15 +1153,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1238,14 +1171,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1255,11 +1188,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 @@ -1271,8 +1204,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1281,7 +1212,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1292,7 +1222,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1303,16 +1233,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1323,14 +1252,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1340,11 +1269,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 @@ -1356,10 +1285,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1377,12 +1302,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1396,22 +1320,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1423,13 +1346,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1457,7 +1376,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1468,7 +1386,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1484,11 +1402,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1499,7 +1416,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1512,18 +1429,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1546,7 +1460,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1554,16 +1468,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1575,13 +1488,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1608,7 +1517,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1619,7 +1527,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1635,11 +1543,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1650,7 +1557,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1663,17 +1570,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1696,7 +1599,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1704,16 +1607,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1725,13 +1627,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1757,7 +1655,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1768,7 +1665,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1783,11 +1680,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1798,7 +1694,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1811,17 +1707,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1844,7 +1736,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1852,16 +1744,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1873,18 +1764,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1898,21 +1785,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1922,11 +1808,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1941,14 +1823,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1975,7 +1849,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -1986,26 +1860,22 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2028,7 +1898,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2036,16 +1906,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2065,10 +1934,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2093,14 +1958,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] @@ -2112,7 +1969,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2127,18 +1984,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] @@ -2150,7 +1999,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2163,19 +2012,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] @@ -2207,7 +2045,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2219,17 +2057,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2244,12 +2080,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2263,21 +2098,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2287,8 +2121,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py index 3479e2c722bd..fe340b19e6eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,22 +269,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +296,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -316,12 +315,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +333,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,13 +360,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -386,12 +379,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,22 +397,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,13 +424,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -458,12 +445,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,22 +463,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -503,11 +488,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -520,7 +501,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -531,7 +511,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -542,17 +522,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -563,14 +542,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -580,11 +559,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 @@ -596,7 +575,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py index 0ef8cff9b85c..b94df1db7d41 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -176,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -222,13 +225,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -260,7 +259,6 @@ def set_service_properties( :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: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +270,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum35], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,11 +290,10 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +305,7 @@ def set_service_properties( resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum35], - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -326,17 +323,13 @@ def set_service_properties( :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties 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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +352,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, @@ -368,16 +361,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +382,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -415,12 +403,11 @@ def get_service_properties( :param table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. "default" Required. :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +421,21 @@ def get_service_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,10 +448,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py index 0fd6b58e0a07..f09a6eef31ea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-04-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py index b374634553ab..b6d027dc64f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-06-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json index 72c61eabc68b..cdc805df4ea8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py index 0a241dbf50b5..b39d558d3e45 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -112,7 +114,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -166,7 +186,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-06-01") - 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 @@ -186,7 +206,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py index 6d49fae9ec6b..fa741b201cef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-06-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py index a3cc8424c8e1..bf308736b008 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -169,7 +189,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-06-01") - 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 @@ -189,7 +211,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py index f8d00a495b68..7ab4691b7a23 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_06_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItem] @@ -118,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -137,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -153,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -170,11 +168,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 @@ -186,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -222,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -292,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -334,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -398,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -431,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -466,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -508,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -555,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -709,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -743,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -759,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -779,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -821,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -881,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -914,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -930,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -949,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -991,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1012,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1057,11 +995,6 @@ async def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1074,7 +1007,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1100,15 +1033,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1121,7 +1049,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1144,21 +1072,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,7 +1105,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1196,16 +1116,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1220,13 +1139,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1256,16 +1171,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1280,7 +1190,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1288,16 +1198,15 @@ async def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,13 +1221,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1345,16 +1250,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1369,7 +1269,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1377,16 +1277,15 @@ async def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1401,13 +1300,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1432,12 +1327,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,23 +1345,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,13 +1375,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1528,7 +1417,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1541,7 +1429,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1568,11 +1456,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1585,7 +1472,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1609,17 +1496,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1645,7 +1528,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1655,16 +1538,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1679,13 +1561,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1718,7 +1596,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1751,11 +1628,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,7 +1643,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1785,18 +1661,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,7 +1694,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1831,16 +1703,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1852,18 +1723,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,22 +1744,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,11 +1768,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1929,14 +1791,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1964,7 +1818,7 @@ async def begin_object_level_worm( 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( @@ -1975,14 +1829,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py index a351968ab08f..643de8223d56 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +131,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +164,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +194,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +209,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -229,17 +226,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +255,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -271,16 +264,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +353,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +368,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy] @@ -398,7 +379,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +390,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +410,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -447,11 +427,11 @@ async def extract_data(pipeline_response): 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 @@ -463,7 +443,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py index fe88ad0ebbd6..fb23043de6e1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,10 +36,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -90,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -185,11 +179,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +189,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -217,15 +206,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -236,7 +220,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -251,21 +235,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +265,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -298,16 +274,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,13 +294,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -341,16 +312,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,22 +331,21 @@ async def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,10 +357,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py index d34217323fee..2c1c9c108721 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py index 96ec81c85955..edca3705f59d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py index b5910f2770b8..397fa8cbab87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,13 +116,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -152,11 +146,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -167,7 +156,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -184,15 +173,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -203,7 +187,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -217,22 +201,14 @@ async def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +232,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -265,16 +241,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +262,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -309,16 +280,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -333,22 +299,21 @@ async def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,10 +326,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py index 36ee8586e172..ea2d37444316 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -173,10 +176,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -213,7 +212,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -225,7 +223,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -248,14 +246,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -267,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -287,21 +284,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -324,7 +317,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -334,16 +327,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,10 +356,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -399,7 +387,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +398,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +419,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +434,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -466,18 +452,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +482,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -509,16 +491,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +512,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -569,12 +546,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,7 +564,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -596,16 +572,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +593,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -660,12 +631,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -679,7 +649,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -687,16 +657,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -707,11 +676,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -743,7 +708,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -755,7 +719,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -775,11 +739,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -791,7 +754,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -808,17 +771,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -841,7 +800,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -850,16 +809,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -870,11 +828,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -911,7 +865,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -924,7 +877,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -948,11 +901,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -965,7 +917,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -986,18 +938,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1023,7 +971,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1033,16 +981,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1058,10 +1005,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py index 172fb62ac509..c01f4c29e300 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py index e8babe763fe5..b9fda209fff7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py index 752337f80f32..b4b4862e0094 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py index 8b91dd9c1cf8..3cdaa2cbaaf0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.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.storage.v2021_06_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py index 11be758501ef..bce62b832177 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_06_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py index 62847cae9adb..69882ae9043e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +219,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -259,7 +253,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +264,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -291,11 +284,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -307,7 +299,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -325,17 +317,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +346,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -367,16 +355,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,13 +376,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -415,12 +398,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +416,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,13 +443,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -488,12 +465,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,22 +483,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -533,11 +508,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -563,7 +534,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueue] @@ -575,7 +545,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,19 +556,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -609,14 +578,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -626,11 +595,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 @@ -642,7 +611,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py index 5156cdaa5bbf..7f8f0b75ee56 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,13 +116,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -152,11 +146,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -167,7 +156,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -184,15 +173,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -203,7 +187,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -218,21 +202,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +232,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -265,16 +241,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +262,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -309,16 +280,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -333,22 +299,21 @@ async def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,10 +326,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py index 63608f9f678e..4047090dbedc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py index 94003fb1cf4e..d552d004e509 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -51,10 +51,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +97,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -105,18 +104,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -124,25 +122,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -192,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,7 +220,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -238,16 +228,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,13 +250,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -296,14 +281,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -316,7 +293,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -334,18 +311,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -358,7 +327,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -374,19 +343,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -419,7 +378,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -429,17 +388,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -454,12 +411,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,21 +429,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,11 +452,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -527,12 +478,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_06_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,22 +496,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,13 +522,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -612,7 +557,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -623,7 +567,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -645,11 +589,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -660,7 +603,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -680,17 +623,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,7 +653,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -721,16 +661,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,20 +681,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] @@ -767,7 +701,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,15 +712,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -797,14 +730,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -814,11 +747,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 @@ -830,8 +763,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -842,7 +773,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] @@ -854,7 +784,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,16 +795,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -885,14 +814,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -902,11 +831,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 @@ -918,10 +847,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -939,12 +864,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,22 +882,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,13 +908,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1019,7 +938,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,7 +948,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1046,11 +964,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1061,7 +978,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1074,18 +991,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1108,7 +1022,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1116,16 +1030,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1137,13 +1050,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1170,7 +1079,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1181,7 +1089,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1197,11 +1105,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1119,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1225,17 +1132,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,7 +1161,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1266,16 +1169,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1287,13 +1189,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1319,7 +1217,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1330,7 +1227,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1345,11 +1242,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1360,7 +1256,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1373,17 +1269,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,7 +1298,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1414,16 +1306,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,18 +1326,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,21 +1347,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1484,11 +1370,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1503,14 +1385,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1537,7 +1411,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1548,22 +1422,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1577,22 +1447,21 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1603,11 +1472,7 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_hierarchical_namespace_migration( @@ -1627,14 +1492,6 @@ async def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1662,7 +1519,7 @@ async def begin_hierarchical_namespace_migration( 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( @@ -1673,22 +1530,18 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } - - async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1702,21 +1555,20 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1727,14 +1579,10 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -1746,14 +1594,6 @@ async def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1780,7 +1620,7 @@ async def begin_abort_hierarchical_namespace_migration( 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( @@ -1791,26 +1631,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1833,7 +1669,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1841,16 +1677,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1870,10 +1705,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1898,14 +1729,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1918,7 +1741,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1933,18 +1756,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1957,7 +1772,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1970,19 +1785,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2015,7 +1819,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2027,17 +1831,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2052,12 +1854,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2071,21 +1872,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2095,8 +1895,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py index 2402055d7225..9297575e2060 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,13 +127,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -149,12 +148,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,22 +166,21 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,13 +193,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -219,12 +212,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,22 +230,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,13 +257,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -291,12 +278,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,22 +296,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -336,11 +321,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -353,7 +334,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +344,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,17 +355,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -396,14 +375,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -413,11 +392,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 @@ -429,7 +408,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py index 86258070ceaa..7c0440eae2ac 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,13 +116,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -152,11 +146,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -167,7 +156,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -184,15 +173,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -203,7 +187,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -218,21 +202,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +232,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -265,16 +241,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +262,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -309,16 +280,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -333,22 +299,21 @@ async def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,10 +326,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py index ff628395906f..4cd289671675 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py index cc59abc665f8..7e7427261fbb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -128,7 +122,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -230,7 +224,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -307,7 +301,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. Ex - - /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 @@ -342,7 +336,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -376,7 +370,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -438,7 +432,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -612,7 +606,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -659,7 +653,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyFilter @@ -808,7 +802,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -867,7 +861,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -916,7 +910,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -951,7 +945,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -1051,7 +1045,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1373,7 +1367,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1470,7 +1464,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1506,7 +1500,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1582,7 +1576,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. Ex - - /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 @@ -1591,22 +1585,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1614,7 +1592,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1698,7 +1676,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1793,7 +1771,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_06_01.models.EncryptionServices @@ -1883,7 +1861,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2311,7 +2289,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2383,7 +2361,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2541,7 +2519,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2770,7 +2748,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2830,7 +2808,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3084,7 +3062,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -3146,7 +3124,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3227,7 +3205,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3287,10 +3265,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3329,7 +3307,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3384,10 +3362,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3426,7 +3404,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3483,7 +3461,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3630,7 +3608,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3834,7 +3812,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3998,7 +3976,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4134,7 +4112,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyAction @@ -4173,7 +4151,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4222,7 +4200,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4279,7 +4257,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4496,7 +4474,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -4589,7 +4567,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4692,7 +4670,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -4886,7 +4864,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4971,7 +4949,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. Ex - - /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 @@ -5140,7 +5118,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5208,7 +5186,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5341,7 +5319,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5380,7 +5358,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -5603,7 +5581,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5673,7 +5651,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5812,10 +5790,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. Ex - - /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 @@ -5860,10 +5838,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -6188,12 +6166,12 @@ def __init__( # pylint: disable=too-many-locals self.immutable_storage_with_versioning = immutable_storage_with_versioning -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -6226,7 +6204,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku @@ -6679,7 +6657,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -6941,7 +6919,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7074,7 +7052,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7111,7 +7089,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7151,7 +7129,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -7441,10 +7419,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -7474,7 +7452,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py index 01df710050bf..1cffd9d76024 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py @@ -260,7 +260,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -280,7 +279,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py index 6e688814b279..fd5e13208ba1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -300,7 +300,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -639,7 +639,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_06_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +649,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -661,7 +660,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -669,12 +668,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -685,14 +683,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -702,11 +700,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 @@ -718,10 +716,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -754,7 +748,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -766,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,11 +781,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -804,7 +796,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -824,17 +816,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +845,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -866,16 +854,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -895,10 +882,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -930,7 +913,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -942,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -963,11 +945,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -979,7 +960,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -998,17 +979,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1031,7 +1008,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1040,16 +1017,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1061,13 +1037,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1087,12 +1059,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,22 +1077,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,13 +1103,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1159,12 +1125,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1178,22 +1143,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1203,11 +1167,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1241,7 +1201,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1253,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1275,11 +1234,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1291,7 +1249,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1311,17 +1269,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1344,7 +1298,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1353,16 +1307,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1374,13 +1327,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1413,7 +1362,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1425,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1446,11 +1394,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1462,7 +1409,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1481,17 +1428,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1514,7 +1457,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1523,16 +1466,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1544,13 +1486,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1589,11 +1527,6 @@ def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1606,7 +1539,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1632,15 +1565,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1653,7 +1581,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1676,21 +1604,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1717,7 +1637,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1728,16 +1648,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1752,13 +1671,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1788,16 +1703,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1812,7 +1722,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1820,16 +1730,15 @@ def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1844,13 +1753,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1877,16 +1782,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1901,7 +1801,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1909,16 +1809,15 @@ def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1933,13 +1832,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1964,12 +1859,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1983,23 +1877,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2014,13 +1907,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2060,7 +1949,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2073,7 +1961,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2100,11 +1988,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2117,7 +2004,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2141,17 +2028,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2177,7 +2060,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2187,16 +2070,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2211,13 +2093,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2250,7 +2128,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2262,7 +2139,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2283,11 +2160,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2299,7 +2175,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2317,18 +2193,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2354,7 +2226,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2363,16 +2235,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2384,18 +2255,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2409,22 +2276,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2434,11 +2300,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2461,14 +2323,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2496,7 +2350,7 @@ def begin_object_level_worm( 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( @@ -2507,14 +2361,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py index 42c428b2a579..1e2aa0f7ee66 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +276,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -310,7 +309,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +339,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,7 +354,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -374,17 +371,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +400,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -416,16 +409,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,13 +430,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -467,12 +455,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,22 +473,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,11 +498,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -531,7 +513,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy] @@ -543,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +535,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +555,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -592,11 +572,11 @@ def extract_data(pipeline_response): 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 @@ -608,7 +588,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py index 60bdf86abdbd..09517a76d6e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -179,7 +179,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -192,7 +191,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,17 +202,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -224,14 +222,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -241,11 +239,11 @@ def extract_data(pipeline_response): 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 @@ -257,10 +255,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -287,11 +281,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +291,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -319,15 +308,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +322,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -353,21 +337,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +367,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -400,16 +376,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +396,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -443,16 +414,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,22 +433,21 @@ def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,10 +459,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py index 490ccdb93dc9..6d51302ffe3e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py index 51395d946e5c..38d1e98e2dd7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py index 1d4151baa783..09c0e1f15df9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +219,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -255,11 +249,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +259,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -287,15 +276,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +290,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -320,22 +304,14 @@ def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +335,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -368,16 +344,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +365,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -412,16 +383,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +402,21 @@ def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -464,10 +429,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py index dc6eb0a309b2..b07322e038ce 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -386,7 +391,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +401,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,7 +412,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -416,12 +420,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -432,14 +435,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -449,11 +452,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 @@ -466,10 +469,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -506,7 +505,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -518,7 +516,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -541,14 +539,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -560,7 +557,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -580,21 +577,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -617,7 +610,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -627,16 +620,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -657,10 +649,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -692,7 +680,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -704,7 +691,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -725,11 +712,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -741,7 +727,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -759,18 +745,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -793,7 +775,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -802,16 +784,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -824,13 +805,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -862,12 +839,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -881,7 +857,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -889,16 +865,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -911,13 +886,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -953,12 +924,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -972,7 +942,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -980,16 +950,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1000,11 +969,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1036,7 +1001,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1048,7 +1012,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1068,11 +1032,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1084,7 +1047,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1101,17 +1064,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1134,7 +1093,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1143,16 +1102,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1163,11 +1121,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1204,7 +1158,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1217,7 +1170,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1241,11 +1194,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1258,7 +1210,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1279,18 +1231,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1316,7 +1264,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1326,16 +1274,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1351,10 +1298,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py index a20fa3201743..92c800bb0ad2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py index 208bd6c0b4e5..e2c9f586f3cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +330,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,13 +357,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +424,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +439,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -466,17 +457,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +487,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -508,16 +496,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,13 +517,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -556,12 +539,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +557,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,8 +582,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py index f4a53775c81f..e5234b1530f7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py index c8819b67ab3c..ea3b9f828753 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_06_01.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.storage.v2021_06_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py index 35361af41d7d..964448f398ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_06_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py index 4a925fb4c185..7344a3114742 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,13 +428,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -468,7 +462,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -480,7 +473,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -500,11 +493,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -516,7 +508,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -534,17 +526,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -567,7 +555,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -576,16 +564,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -598,13 +585,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -622,12 +605,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -641,22 +623,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -669,13 +650,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -695,12 +672,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -714,22 +690,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,11 +715,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -770,7 +741,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -781,7 +751,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -792,19 +762,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -815,14 +784,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -832,11 +801,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 @@ -848,7 +817,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py index a570f197afe2..7f24a8cf8d0a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +219,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -255,11 +249,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +259,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -287,15 +276,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +290,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -321,21 +305,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +335,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -368,16 +344,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +365,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -412,16 +383,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +402,21 @@ def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -464,10 +429,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py index 3ff82550f867..87c273564cf4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py index c5bab8105ead..1683774b7aad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -441,7 +441,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request( +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -475,7 +475,7 @@ def build_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request( +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -544,7 +544,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -609,7 +609,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -617,18 +616,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -636,25 +634,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +672,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -704,22 +698,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,7 +732,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -750,16 +740,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -773,13 +762,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -808,14 +793,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] @@ -827,7 +804,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -845,18 +822,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] @@ -868,7 +837,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -884,19 +853,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] @@ -928,7 +887,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -938,17 +897,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -963,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,21 +938,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1006,11 +961,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -1036,12 +987,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_06_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1055,22 +1005,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1082,13 +1031,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1121,7 +1066,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1132,7 +1076,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1154,11 +1098,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1169,7 +1112,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1189,17 +1132,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1222,7 +1162,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1230,16 +1170,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,20 +1190,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1275,7 +1209,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1286,15 +1220,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1305,14 +1238,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1322,11 +1255,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 @@ -1338,8 +1271,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1348,7 +1279,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1359,7 +1289,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1370,16 +1300,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1390,14 +1319,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1407,11 +1336,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 @@ -1423,10 +1352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1444,12 +1369,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1463,22 +1387,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1490,13 +1413,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1524,7 +1443,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1453,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1551,11 +1469,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1483,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1579,18 +1496,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1613,7 +1527,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1621,16 +1535,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1555,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1675,7 +1584,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1686,7 +1594,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1702,11 +1610,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1717,7 +1624,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1730,17 +1637,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1763,7 +1666,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1771,16 +1674,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1792,13 +1694,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1824,7 +1722,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1835,7 +1732,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1850,11 +1747,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1865,7 +1761,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1878,17 +1774,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1911,7 +1803,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1919,16 +1811,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1940,18 +1831,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1965,21 +1852,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1989,11 +1875,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -2008,14 +1890,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2042,7 +1916,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -2053,22 +1927,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2082,22 +1952,21 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2108,11 +1977,7 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_hierarchical_namespace_migration( @@ -2132,14 +1997,6 @@ def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2167,7 +2024,7 @@ def begin_hierarchical_namespace_migration( 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( @@ -2178,22 +2035,18 @@ 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_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2207,21 +2060,20 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2232,14 +2084,10 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -2251,14 +2099,6 @@ def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2285,7 +2125,7 @@ def begin_abort_hierarchical_namespace_migration( 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( @@ -2296,26 +2136,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2338,7 +2174,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2346,16 +2182,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2375,10 +2210,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2403,14 +2234,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] @@ -2422,7 +2245,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2437,18 +2260,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] @@ -2460,7 +2275,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2473,19 +2288,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] @@ -2517,7 +2321,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2529,17 +2333,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2554,12 +2356,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2573,21 +2374,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2597,8 +2397,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py index 32a18b5db08d..ce22e2629fa1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,22 +269,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +296,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -316,12 +315,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +333,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,13 +360,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -386,12 +379,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,22 +397,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,13 +424,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -458,12 +445,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,22 +463,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -503,11 +488,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -520,7 +501,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -531,7 +511,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -542,17 +522,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -563,14 +542,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -580,11 +559,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 @@ -596,7 +575,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py index e4c7e0b2c2ea..8801a3709803 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +219,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -255,11 +249,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +259,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -287,15 +276,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +290,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -321,21 +305,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +335,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -368,16 +344,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,13 +365,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -412,16 +383,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +402,21 @@ def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -464,10 +429,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py index fa6d653a893f..4a3c9d02bd25 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py index c8e433770dc4..66be34441ed7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-08-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json index 31d39c4613f0..0feb8c85b60d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py index 21a41f5f0bc9..08ff81b2be8e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -172,7 +192,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-08-01") - 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 @@ -192,7 +212,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py index bad3f00159e9..7b440e630a90 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-08-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py index 4891657ba467..7ca4b87dd0ad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -118,7 +120,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -175,7 +195,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-08-01") - 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 @@ -195,7 +217,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py index 170e77dc4154..3c60276f45e0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_08_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItem] @@ -118,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -137,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -153,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -170,11 +168,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 @@ -186,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -222,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -292,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -334,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -398,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -431,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -466,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -508,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -555,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -709,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -743,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -759,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -779,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -821,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -881,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -914,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -930,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -949,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -991,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1012,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1057,11 +995,6 @@ async def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1074,7 +1007,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1100,15 +1033,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1121,7 +1049,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1144,21 +1072,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,7 +1105,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1196,16 +1116,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1220,13 +1139,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1256,16 +1171,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1280,7 +1190,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1288,16 +1198,15 @@ async def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,13 +1221,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1345,16 +1250,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1369,7 +1269,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1377,16 +1277,15 @@ async def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1401,13 +1300,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1432,12 +1327,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,23 +1345,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,13 +1375,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1528,7 +1417,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1541,7 +1429,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1568,11 +1456,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1585,7 +1472,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1609,17 +1496,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1645,7 +1528,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1655,16 +1538,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1679,13 +1561,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1718,7 +1596,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1751,11 +1628,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,7 +1643,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1785,18 +1661,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,7 +1694,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1831,16 +1703,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1852,18 +1723,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,22 +1744,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,11 +1768,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1929,14 +1791,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1964,7 +1818,7 @@ async def begin_object_level_worm( 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( @@ -1975,14 +1829,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py index 94c34166dddf..3bf3ad5af3ec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,13 +131,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +164,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +175,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +194,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +209,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -229,17 +226,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +255,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -271,16 +264,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,13 +285,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -322,12 +310,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +328,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +353,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +368,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy] @@ -398,7 +379,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,17 +390,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -430,14 +410,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -447,11 +427,11 @@ async def extract_data(pipeline_response): 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 @@ -463,7 +443,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py index a776499f687f..252df2f9d0b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,10 +36,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -90,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -185,11 +179,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +189,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -217,15 +206,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -236,7 +220,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -251,21 +235,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +265,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -298,16 +274,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,13 +294,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -341,16 +312,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,22 +331,21 @@ async def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,10 +357,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py index 418848ee289f..e78e783dcaf4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py index b13efe719976..fbcf6f0d9ae7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py index 5f243c3f82d9..fdf62a856d2f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -216,22 +200,14 @@ async def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py index 3182418a467b..196ed2f027d8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -172,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -212,7 +211,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -224,7 +222,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -247,14 +245,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -286,21 +283,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +316,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +326,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +354,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +385,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +396,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +417,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +432,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +450,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +480,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +489,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +509,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +543,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +561,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +569,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +589,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +627,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +645,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -683,16 +653,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +671,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -738,7 +703,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -750,7 +714,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,11 +734,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -786,7 +749,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -803,17 +766,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +795,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -845,16 +804,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -864,11 +822,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -905,7 +859,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -918,7 +871,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -942,11 +895,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -959,7 +911,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -980,18 +932,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1017,7 +965,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1027,16 +975,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1051,10 +998,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py index 011ba47bd534..88ad058e449a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,6 +39,10 @@ build_regenerate_password_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]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUser] @@ -85,7 +89,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -169,12 +168,11 @@ async def get(self, resource_group_name: str, account_name: str, username: str, :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get(self, resource_group_name: str, account_name: str, username: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,13 +213,9 @@ async def get(self, resource_group_name: str, account_name: str, username: str, deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -252,7 +245,6 @@ async def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +256,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,11 +274,10 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +289,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -314,17 +305,13 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +334,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -356,16 +343,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,13 +364,9 @@ async def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -402,12 +384,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,22 +402,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -447,11 +427,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def list_keys( @@ -469,12 +445,11 @@ async def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,22 +463,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,13 +490,9 @@ async def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace_async async def regenerate_password( @@ -540,12 +510,11 @@ async def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,22 +528,21 @@ async def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -587,10 +555,6 @@ async def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py index 7791e5b5a0de..9d8de1146a7d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py index d7827897bda1..02f797f0caa0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py index cc12db6cb634..ea25226df226 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py index 1dce59825e4a..bd29831dca33 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.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.storage.v2021_08_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py index b4a4b1c142f7..caf48f3dca5c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_08_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py index ff697da61558..b379ad307a7a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py index 1efd6225243c..0eeccb2f2352 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py index 49717faad322..8993bfbb841f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py index 139dd1224e83..b40b786af1d1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -51,10 +51,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +97,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -105,18 +104,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -124,25 +122,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -192,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,7 +220,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -238,16 +228,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,13 +250,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -296,14 +281,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -316,7 +293,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -334,18 +311,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -358,7 +327,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -374,19 +343,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -419,7 +378,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -429,17 +388,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -454,12 +411,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,21 +429,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,11 +452,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -527,12 +478,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_08_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,22 +496,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,13 +522,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -612,7 +557,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -623,7 +567,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -645,11 +589,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -660,7 +603,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -680,17 +623,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,7 +653,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -721,16 +661,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,20 +681,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] @@ -767,7 +701,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,15 +712,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -797,14 +730,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -814,11 +747,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 @@ -830,8 +763,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -842,7 +773,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] @@ -854,7 +784,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,16 +795,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -885,14 +814,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -902,11 +831,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 @@ -918,10 +847,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -939,12 +864,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,22 +882,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,13 +908,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1019,7 +938,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,7 +948,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1046,11 +964,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1061,7 +978,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1074,18 +991,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1108,7 +1022,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1116,16 +1030,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1137,13 +1050,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1170,7 +1079,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1181,7 +1089,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1197,11 +1105,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1119,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1225,17 +1132,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,7 +1161,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1266,16 +1169,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1287,13 +1189,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1319,7 +1217,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1330,7 +1227,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1345,11 +1242,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1360,7 +1256,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1373,17 +1269,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,7 +1298,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1414,16 +1306,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,18 +1326,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,21 +1347,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1484,11 +1370,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1503,14 +1385,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1537,7 +1411,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1548,22 +1422,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1577,22 +1447,21 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1603,11 +1472,7 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_hierarchical_namespace_migration( @@ -1627,14 +1492,6 @@ async def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1662,7 +1519,7 @@ async def begin_hierarchical_namespace_migration( 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( @@ -1673,22 +1530,18 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } - - async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1702,21 +1555,20 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1727,14 +1579,10 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -1746,14 +1594,6 @@ async def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1780,7 +1620,7 @@ async def begin_abort_hierarchical_namespace_migration( 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( @@ -1791,26 +1631,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1833,7 +1669,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1841,16 +1677,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1870,10 +1705,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1898,14 +1729,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1918,7 +1741,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1933,18 +1756,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1957,7 +1772,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1970,19 +1785,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2015,7 +1819,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2027,17 +1831,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2052,12 +1854,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2071,21 +1872,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2095,8 +1895,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py index 0c521c18cc2b..dfdca9390935 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_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,8 @@ # 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 @@ -36,6 +37,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]] @@ -77,12 +82,11 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def update( @@ -148,12 +147,11 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,22 +165,21 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,13 +191,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -217,12 +210,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,22 +228,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -263,13 +254,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -288,12 +275,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,22 +293,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,11 +317,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -349,7 +330,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -360,7 +340,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,17 +351,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -392,14 +371,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -409,11 +388,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 @@ -424,7 +403,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py index 1706a71c318d..a5283a549439 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py index 861d78b25b1e..4b492a5cde16 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py index 6f99a86a128b..49ab5097390b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -128,7 +122,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -230,7 +224,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -325,7 +319,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. Ex - - /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 @@ -360,7 +354,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -394,7 +388,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -456,7 +450,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -630,7 +624,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -677,7 +671,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyFilter @@ -826,7 +820,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -885,7 +879,7 @@ def __init__( class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. - 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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -934,7 +928,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -969,7 +963,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -1069,7 +1063,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1319,7 +1313,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1416,7 +1410,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1452,7 +1446,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1528,7 +1522,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. Ex - - /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 @@ -1537,22 +1531,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1560,7 +1538,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1644,7 +1622,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1739,7 +1717,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_08_01.models.EncryptionServices @@ -1845,7 +1823,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2272,7 +2250,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2344,7 +2322,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2502,7 +2480,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2731,7 +2709,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2791,7 +2769,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3045,7 +3023,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -3107,7 +3085,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3188,7 +3166,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3248,10 +3226,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3290,7 +3268,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3345,10 +3323,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3387,7 +3365,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3444,7 +3422,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3591,7 +3569,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3795,7 +3773,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3959,7 +3937,7 @@ class LocalUser(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4128,7 +4106,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4264,7 +4242,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyAction @@ -4303,7 +4281,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4352,7 +4330,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4409,7 +4387,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4626,7 +4604,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -4719,7 +4697,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4822,7 +4800,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -4990,7 +4968,7 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg class PermissionScope(_serialization.Model): """PermissionScope. - 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 permissions: The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c). Required. @@ -5060,7 +5038,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5145,7 +5123,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. Ex - - /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 @@ -5314,7 +5292,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5382,7 +5360,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5515,7 +5493,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5554,7 +5532,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -5777,7 +5755,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5847,7 +5825,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -6014,10 +5992,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. Ex - - /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 @@ -6062,10 +6040,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -6413,12 +6391,12 @@ def __init__( # pylint: disable=too-many-locals self.allowed_copy_scope = allowed_copy_scope -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -6451,7 +6429,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku @@ -6927,7 +6905,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -7212,7 +7190,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7345,7 +7323,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7382,7 +7360,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7422,7 +7400,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -7712,10 +7690,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -7745,7 +7723,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py index fc793d2bab73..cc58b31a097a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py @@ -276,7 +276,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -296,7 +295,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py index 5642b6da93fa..2f35170db5f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -300,7 +300,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -639,7 +639,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_08_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +649,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -661,7 +660,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -669,12 +668,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -685,14 +683,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -702,11 +700,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 @@ -718,10 +716,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -754,7 +748,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -766,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,11 +781,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -804,7 +796,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -824,17 +816,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +845,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -866,16 +854,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -895,10 +882,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -930,7 +913,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -942,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -963,11 +945,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -979,7 +960,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -998,17 +979,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1031,7 +1008,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1040,16 +1017,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1061,13 +1037,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1087,12 +1059,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,22 +1077,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,13 +1103,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1159,12 +1125,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1178,22 +1143,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1203,11 +1167,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1241,7 +1201,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1253,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1275,11 +1234,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1291,7 +1249,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1311,17 +1269,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1344,7 +1298,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1353,16 +1307,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1374,13 +1327,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1413,7 +1362,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1425,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1446,11 +1394,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1462,7 +1409,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1481,17 +1428,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1514,7 +1457,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1523,16 +1466,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1544,13 +1486,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1589,11 +1527,6 @@ def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1606,7 +1539,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1632,15 +1565,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1653,7 +1581,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1676,21 +1604,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1717,7 +1637,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1728,16 +1648,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1752,13 +1671,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1788,16 +1703,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1812,7 +1722,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1820,16 +1730,15 @@ def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1844,13 +1753,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1877,16 +1782,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1901,7 +1801,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1909,16 +1809,15 @@ def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1933,13 +1832,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1964,12 +1859,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1983,23 +1877,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2014,13 +1907,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2060,7 +1949,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2073,7 +1961,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2100,11 +1988,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2117,7 +2004,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2141,17 +2028,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2177,7 +2060,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2187,16 +2070,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2211,13 +2093,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2250,7 +2128,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2262,7 +2139,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2283,11 +2160,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2299,7 +2175,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2317,18 +2193,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2354,7 +2226,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2363,16 +2235,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2384,18 +2255,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2409,22 +2276,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2434,11 +2300,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2461,14 +2323,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2496,7 +2350,7 @@ def begin_object_level_worm( 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( @@ -2507,14 +2361,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py index 0eda7b6a62ae..c4d305106d8d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +276,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -310,7 +309,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -341,11 +339,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,7 +354,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -374,17 +371,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +400,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -416,16 +409,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,13 +430,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -467,12 +455,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,22 +473,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,11 +498,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -531,7 +513,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy] @@ -543,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,17 +535,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -575,14 +555,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -592,11 +572,11 @@ def extract_data(pipeline_response): 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 @@ -608,7 +588,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py index ea2b429043ea..d6388ba48216 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -179,7 +179,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -192,7 +191,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,17 +202,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -224,14 +222,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -241,11 +239,11 @@ def extract_data(pipeline_response): 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 @@ -257,10 +255,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -287,11 +281,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +291,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -319,15 +308,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +322,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -353,21 +337,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +367,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -400,16 +376,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +396,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -443,16 +414,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,22 +433,21 @@ def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,10 +459,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py index 1598006ad58a..a76147a14102 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py index f2a859827efb..d3f79089c249 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py index 016b99754f21..10444d0be5f5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -319,22 +303,14 @@ def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py index 4834d7d5c7aa..0ff00855c7e8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -386,7 +391,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +401,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,7 +412,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -416,12 +420,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -432,14 +435,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -449,11 +452,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 @@ -465,10 +468,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -505,7 +504,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -517,7 +515,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -540,14 +538,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -559,7 +556,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -579,21 +576,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,7 +609,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -626,16 +619,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -655,10 +647,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -690,7 +678,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -702,7 +689,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -723,11 +710,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -739,7 +725,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -757,18 +743,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,7 +773,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -800,16 +782,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -821,13 +802,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -859,12 +836,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +854,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -886,16 +862,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -907,13 +882,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -949,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -968,7 +938,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -976,16 +946,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -995,11 +964,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1031,7 +996,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1043,7 +1007,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1063,11 +1027,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1079,7 +1042,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1096,17 +1059,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1129,7 +1088,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1138,16 +1097,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1157,11 +1115,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1198,7 +1152,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1211,7 +1164,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1235,11 +1188,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1252,7 +1204,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1273,18 +1225,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1310,7 +1258,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1320,16 +1268,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1344,10 +1291,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py index 3774a96ea9a5..68979da57553 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -272,7 +277,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUser] :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +287,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,17 +298,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -315,14 +318,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -332,11 +335,11 @@ def extract_data(pipeline_response): 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 @@ -349,10 +352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -367,12 +366,11 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,22 +384,21 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,13 +411,9 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -450,7 +443,6 @@ def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -480,11 +472,10 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +487,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -512,17 +503,13 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -545,7 +532,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -554,16 +541,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -576,13 +562,9 @@ def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -600,12 +582,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,22 +600,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -645,11 +625,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_keys( @@ -667,12 +643,11 @@ def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -686,22 +661,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +688,9 @@ def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace def regenerate_password( @@ -738,12 +708,11 @@ def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,22 +726,21 @@ def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -785,10 +753,6 @@ def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py index 4b6304ba8110..57a0be97814b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py index a21370c56113..06bf8cc91646 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +330,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,13 +357,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +424,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +439,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -466,17 +457,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +487,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -508,16 +496,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,13 +517,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -556,12 +539,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +557,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,8 +582,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py index 90f7df0bf327..9bc97e1b9478 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py index 27ed9d577a33..9873447dbabb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_08_01.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.storage.v2021_08_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py index fe16d518e7d1..8a0b95c2382e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_08_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py index 632736df9011..8a247a770076 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py index 00ac88cfc620..547a52f4847c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py index 233e037ae08b..dadecc647a04 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py index 57a5f5d25f95..3d2da0f70008 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -441,7 +441,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request( +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -475,7 +475,7 @@ def build_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request( +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -544,7 +544,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -609,7 +609,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -617,18 +616,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -636,25 +634,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +672,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -704,22 +698,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,7 +732,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -750,16 +740,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -773,13 +762,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -808,14 +793,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] @@ -827,7 +804,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -845,18 +822,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] @@ -868,7 +837,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -884,19 +853,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] @@ -928,7 +887,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -938,17 +897,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -963,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,21 +938,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1006,11 +961,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -1036,12 +987,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_08_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1055,22 +1005,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1082,13 +1031,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1121,7 +1066,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1132,7 +1076,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1154,11 +1098,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1169,7 +1112,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1189,17 +1132,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1222,7 +1162,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1230,16 +1170,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,20 +1190,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1275,7 +1209,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1286,15 +1220,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1305,14 +1238,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1322,11 +1255,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 @@ -1338,8 +1271,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1348,7 +1279,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1359,7 +1289,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1370,16 +1300,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1390,14 +1319,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1407,11 +1336,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 @@ -1423,10 +1352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1444,12 +1369,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1463,22 +1387,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1490,13 +1413,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1524,7 +1443,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1453,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1551,11 +1469,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1483,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1579,18 +1496,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1613,7 +1527,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1621,16 +1535,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1555,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1675,7 +1584,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1686,7 +1594,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1702,11 +1610,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1717,7 +1624,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1730,17 +1637,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1763,7 +1666,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1771,16 +1674,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1792,13 +1694,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1824,7 +1722,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1835,7 +1732,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1850,11 +1747,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1865,7 +1761,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1878,17 +1774,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1911,7 +1803,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1919,16 +1811,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1940,18 +1831,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1965,21 +1852,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1989,11 +1875,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -2008,14 +1890,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2042,7 +1916,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -2053,22 +1927,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2082,22 +1952,21 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2108,11 +1977,7 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_hierarchical_namespace_migration( @@ -2132,14 +1997,6 @@ def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2167,7 +2024,7 @@ def begin_hierarchical_namespace_migration( 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( @@ -2178,22 +2035,18 @@ 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_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2207,21 +2060,20 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2232,14 +2084,10 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -2251,14 +2099,6 @@ def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2285,7 +2125,7 @@ def begin_abort_hierarchical_namespace_migration( 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( @@ -2296,26 +2136,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2338,7 +2174,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2346,16 +2182,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2375,10 +2210,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2403,14 +2234,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] @@ -2422,7 +2245,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2437,18 +2260,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] @@ -2460,7 +2275,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2473,19 +2288,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] @@ -2517,7 +2321,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2529,17 +2333,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2554,12 +2356,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2573,21 +2374,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2597,8 +2397,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py index 001eaefc37d3..392047979064 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -246,12 +251,11 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,22 +269,21 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,13 +295,9 @@ def create(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -315,12 +314,11 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,22 +332,21 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,13 +358,9 @@ def update(self, resource_group_name: str, account_name: str, table_name: str, * deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -384,12 +377,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,22 +395,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,13 +421,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -455,12 +442,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,22 +460,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,11 +484,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -516,7 +497,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -527,7 +507,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,17 +518,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +538,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -576,11 +555,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 @@ -591,7 +570,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py index 1ebe015b483f..209759df9e18 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py index 4ffd6029774c..2d708900e11e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-08-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py index 338cfa64d83a..98c6fb75bea0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-09-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json index 471ab72ab125..d704051e9df9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py index 3fd6f253eeba..ebb0de4cb29f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -172,7 +192,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-09-01") - 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 @@ -192,7 +212,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py index ac8ae902ee12..3a595612bb8b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-09-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py index f43296c4e08d..ccfc5e9b23db 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -118,7 +120,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -175,7 +195,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2021-09-01") - 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 @@ -195,7 +217,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py index be107803bfe6..38c5c5fc5bd3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_09_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItem] @@ -118,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -137,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -153,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -170,11 +168,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 @@ -186,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -222,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -292,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -334,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -398,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -431,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -466,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -508,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -555,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -709,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -743,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -759,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -779,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -821,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -881,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -914,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -930,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -949,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -991,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1012,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1057,11 +995,6 @@ async def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1074,7 +1007,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1100,15 +1033,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1121,7 +1049,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1144,21 +1072,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,7 +1105,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1196,16 +1116,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1220,13 +1139,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1256,16 +1171,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1280,7 +1190,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1288,16 +1198,15 @@ async def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,13 +1221,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1345,16 +1250,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1369,7 +1269,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1377,16 +1277,15 @@ async def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1401,13 +1300,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1432,12 +1327,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,23 +1345,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,13 +1375,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1528,7 +1417,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1541,7 +1429,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1568,11 +1456,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1585,7 +1472,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1609,17 +1496,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1645,7 +1528,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1655,16 +1538,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1679,13 +1561,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1718,7 +1596,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1751,11 +1628,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,7 +1643,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1785,18 +1661,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,7 +1694,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1831,16 +1703,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1852,18 +1723,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,22 +1744,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,11 +1768,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1929,14 +1791,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1964,7 +1818,7 @@ async def begin_object_level_worm( 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( @@ -1975,14 +1829,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py index a9209e98cba6..68a809bc29b4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,13 +130,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -164,7 +163,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +174,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -195,11 +193,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -211,7 +208,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -228,17 +225,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,7 +254,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -270,16 +263,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,13 +283,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -320,12 +308,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,22 +326,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,11 +350,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -383,7 +365,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy] @@ -395,7 +376,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,17 +387,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -427,14 +407,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -444,11 +424,11 @@ async def extract_data(pipeline_response): 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 @@ -460,7 +440,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py index d3a3d1b10dd5..81c0346fdada 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,10 +36,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -90,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -185,11 +179,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +189,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -217,15 +206,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -236,7 +220,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -251,21 +235,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +265,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -298,16 +274,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,13 +294,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -341,16 +312,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,22 +331,21 @@ async def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,10 +357,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py index 35cc3ceeed22..a97076c46e36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py index 9cfd686e5120..2d972ae01381 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py index 955976342b64..cc55c8c871b6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -216,22 +200,14 @@ async def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py index f715aaebc9fb..bfeeffd6da12 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -172,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -212,7 +211,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -224,7 +222,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -247,14 +245,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -286,21 +283,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +316,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +326,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +354,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +385,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +396,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +417,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +432,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +450,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +480,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +489,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +509,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +543,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +561,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +569,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +589,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +627,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +645,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -683,16 +653,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +671,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -738,7 +703,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -750,7 +714,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,11 +734,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -786,7 +749,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -803,17 +766,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +795,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -845,16 +804,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -864,11 +822,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -905,7 +859,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -918,7 +871,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -942,11 +895,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -959,7 +911,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -980,18 +932,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1017,7 +965,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1027,16 +975,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1051,10 +998,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py index 3e3a3acbd93a..d67d67b9a0fd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,6 +39,10 @@ build_regenerate_password_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]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUser] @@ -85,7 +89,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -169,12 +168,11 @@ async def get(self, resource_group_name: str, account_name: str, username: str, :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get(self, resource_group_name: str, account_name: str, username: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,13 +213,9 @@ async def get(self, resource_group_name: str, account_name: str, username: str, deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -252,7 +245,6 @@ async def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +256,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,11 +274,10 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +289,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -314,17 +305,13 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +334,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -356,16 +343,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,13 +364,9 @@ async def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -402,12 +384,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,22 +402,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -447,11 +427,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def list_keys( @@ -469,12 +445,11 @@ async def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,22 +463,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,13 +490,9 @@ async def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace_async async def regenerate_password( @@ -540,12 +510,11 @@ async def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,22 +528,21 @@ async def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -587,10 +555,6 @@ async def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py index 9654d5583782..e66c4ac5d7ba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py index a8fc95491332..d4b6d7185f59 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py index 6bd8d0753642..247ff2b3db50 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py index dc130dbf5c9e..c9f112ab935a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.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.storage.v2021_09_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py index 17449a966cc0..3a41dcd4beff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_09_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py index 66e530464709..8de4144ea38c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py index ffb328473895..97da5387c0a5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py index f0fa213bd844..60b5178ce934 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py index 26d94017403f..be274d2086a3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -51,10 +51,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +97,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -105,18 +104,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -124,25 +122,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -192,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,7 +220,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -238,16 +228,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,13 +250,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -296,14 +281,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -316,7 +293,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -334,18 +311,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -358,7 +327,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -374,19 +343,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -419,7 +378,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -429,17 +388,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -454,12 +411,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,21 +429,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,11 +452,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -527,12 +478,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_09_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,22 +496,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,13 +522,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -612,7 +557,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -623,7 +567,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -645,11 +589,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -660,7 +603,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -680,17 +623,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,7 +653,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -721,16 +661,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,20 +681,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] @@ -767,7 +701,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,15 +712,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -797,14 +730,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -814,11 +747,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 @@ -830,8 +763,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -842,7 +773,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] @@ -854,7 +784,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,16 +795,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -885,14 +814,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -902,11 +831,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 @@ -918,10 +847,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -939,12 +864,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,22 +882,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,13 +908,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1019,7 +938,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,7 +948,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1046,11 +964,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1061,7 +978,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1074,18 +991,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1108,7 +1022,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1116,16 +1030,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1137,13 +1050,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1170,7 +1079,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1181,7 +1089,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1197,11 +1105,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1119,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1225,17 +1132,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,7 +1161,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1266,16 +1169,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1287,13 +1189,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1319,7 +1217,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1330,7 +1227,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1345,11 +1242,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1360,7 +1256,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1373,17 +1269,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,7 +1298,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1414,16 +1306,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,18 +1326,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,21 +1347,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1484,11 +1370,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1503,14 +1385,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1537,7 +1411,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1548,22 +1422,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1577,22 +1447,21 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1603,11 +1472,7 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_hierarchical_namespace_migration( @@ -1627,14 +1492,6 @@ async def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1662,7 +1519,7 @@ async def begin_hierarchical_namespace_migration( 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( @@ -1673,22 +1530,18 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } - - async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1702,21 +1555,20 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1727,14 +1579,10 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -1746,14 +1594,6 @@ async def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1780,7 +1620,7 @@ async def begin_abort_hierarchical_namespace_migration( 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( @@ -1791,26 +1631,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1833,7 +1669,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1841,16 +1677,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1870,10 +1705,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1898,14 +1729,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1918,7 +1741,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1933,18 +1756,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1957,7 +1772,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1970,19 +1785,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2015,7 +1819,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2027,17 +1831,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2052,12 +1854,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2071,21 +1872,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2095,8 +1895,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py index 85ddfae548c5..2f7837056403 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -90,7 +95,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -102,7 +106,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -121,11 +125,10 @@ async def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -137,7 +140,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -153,18 +156,14 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload async def update( @@ -257,7 +251,6 @@ async def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +262,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -288,11 +281,10 @@ async def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +296,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -320,18 +312,14 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -410,12 +393,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,22 +411,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,13 +437,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -481,12 +458,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,22 +476,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,11 +500,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -542,7 +513,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,7 +523,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,17 +534,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -585,14 +554,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -602,11 +571,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 @@ -617,7 +586,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py index be1c062b77e4..289f7616738e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py index 290e570df4e4..46a350ed798c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py index fbea299ca117..6a1d7b07dab9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -128,7 +122,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -230,7 +224,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -325,7 +319,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. Ex - - /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 @@ -360,7 +354,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -394,7 +388,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Required. Known values are: "None", "AADDS", and "AD". @@ -456,7 +450,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -630,7 +624,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -677,7 +671,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyFilter @@ -872,7 +866,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -933,7 +927,7 @@ class BlobInventoryPolicySchema(_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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -988,7 +982,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -1023,7 +1017,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -1123,7 +1117,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1373,7 +1367,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1470,7 +1464,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1506,7 +1500,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define snapshot and version action conditions. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1627,7 +1621,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. Ex - - /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 @@ -1636,22 +1630,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1659,7 +1637,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1743,7 +1721,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1855,7 +1833,7 @@ def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = class Encryption(_serialization.Model): """The encryption settings on the storage account. - 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 services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_09_01.models.EncryptionServices @@ -1961,7 +1939,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2388,7 +2366,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2460,7 +2438,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2618,7 +2596,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2847,7 +2825,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2907,7 +2885,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3161,7 +3139,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -3223,7 +3201,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3313,7 +3291,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3373,10 +3351,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3415,7 +3393,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3470,10 +3448,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3512,7 +3490,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3569,7 +3547,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3716,7 +3694,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3920,7 +3898,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4084,7 +4062,7 @@ class LocalUser(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4253,7 +4231,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4389,7 +4367,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyAction @@ -4428,7 +4406,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4477,7 +4455,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4534,7 +4512,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4751,7 +4729,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -4844,7 +4822,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4947,7 +4925,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -5115,7 +5093,7 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg class PermissionScope(_serialization.Model): """PermissionScope. - 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 permissions: The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c). Required. @@ -5185,7 +5163,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5270,7 +5248,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. Ex - - /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 @@ -5439,7 +5417,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5507,7 +5485,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5640,7 +5618,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5679,7 +5657,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -5902,7 +5880,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5972,7 +5950,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -6139,10 +6117,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. Ex - - /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 @@ -6187,10 +6165,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -6567,12 +6545,12 @@ def __init__( # pylint: disable=too-many-locals self.dns_endpoint_type = dns_endpoint_type -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -6605,7 +6583,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku @@ -7098,7 +7076,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -7448,7 +7426,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7581,7 +7559,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7625,7 +7603,7 @@ def __init__( class TableAccessPolicy(_serialization.Model): """Table Access Policy Properties Object. - 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 start_time: Start time of the access policy. :vartype start_time: ~datetime.datetime @@ -7675,7 +7653,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7715,7 +7693,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TableSignedIdentifier(_serialization.Model): """Object to set Table Access Policy. - 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: unique-64-character-value of the stored access policy. Required. :vartype id: str @@ -7753,7 +7731,7 @@ def __init__( class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -8043,10 +8021,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -8076,7 +8054,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py index c3e3e891adb6..93ca2cf7d001 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py @@ -291,7 +291,6 @@ class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -311,7 +310,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py index 6b3be8d2c9c5..209cc2a90885 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -300,7 +300,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -639,7 +639,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_09_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +649,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -661,7 +660,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -669,12 +668,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -685,14 +683,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -702,11 +700,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 @@ -718,10 +716,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -754,7 +748,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -766,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,11 +781,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -804,7 +796,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -824,17 +816,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +845,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -866,16 +854,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -895,10 +882,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -930,7 +913,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -942,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -963,11 +945,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -979,7 +960,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -998,17 +979,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1031,7 +1008,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1040,16 +1017,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1061,13 +1037,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1087,12 +1059,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,22 +1077,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,13 +1103,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1159,12 +1125,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1178,22 +1143,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1203,11 +1167,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1241,7 +1201,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1253,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1275,11 +1234,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1291,7 +1249,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1311,17 +1269,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1344,7 +1298,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1353,16 +1307,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1374,13 +1327,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1413,7 +1362,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1425,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1446,11 +1394,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1462,7 +1409,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1481,17 +1428,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1514,7 +1457,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1523,16 +1466,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1544,13 +1486,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1589,11 +1527,6 @@ def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1606,7 +1539,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1632,15 +1565,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1653,7 +1581,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1676,21 +1604,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1717,7 +1637,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1728,16 +1648,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1752,13 +1671,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1788,16 +1703,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1812,7 +1722,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1820,16 +1730,15 @@ def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1844,13 +1753,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1877,16 +1782,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1901,7 +1801,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1909,16 +1809,15 @@ def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1933,13 +1832,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1964,12 +1859,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1983,23 +1877,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2014,13 +1907,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2060,7 +1949,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2073,7 +1961,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2100,11 +1988,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2117,7 +2004,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2141,17 +2028,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2177,7 +2060,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2187,16 +2070,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2211,13 +2093,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2250,7 +2128,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2262,7 +2139,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2283,11 +2160,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2299,7 +2175,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2317,18 +2193,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2354,7 +2226,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2363,16 +2235,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2384,18 +2255,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2409,22 +2276,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2434,11 +2300,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2461,14 +2323,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2496,7 +2350,7 @@ def begin_object_level_worm( 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( @@ -2507,14 +2361,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py index ec812949d1a0..dd313590bfa7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -272,13 +275,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -309,7 +308,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -321,7 +319,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -340,11 +338,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -356,7 +353,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -373,17 +370,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,7 +399,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -415,16 +408,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,13 +428,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -465,12 +453,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,22 +471,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -509,11 +495,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -528,7 +510,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy] @@ -540,7 +521,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,17 +532,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -572,14 +552,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -589,11 +569,11 @@ def extract_data(pipeline_response): 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 @@ -605,7 +585,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py index 8af2500aefa3..042cec48e32f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -179,7 +179,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -192,7 +191,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,17 +202,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -224,14 +222,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -241,11 +239,11 @@ def extract_data(pipeline_response): 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 @@ -257,10 +255,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -287,11 +281,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +291,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -319,15 +308,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +322,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -353,21 +337,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +367,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -400,16 +376,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +396,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -443,16 +414,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,22 +433,21 @@ def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,10 +459,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py index fa929542b084..69b5cf3ff3be 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py index 3292df67b564..e13665d292d8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py index d7a327a41048..f6259ae9f886 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -319,22 +303,14 @@ def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py index f53b1d547bbb..3a98c6c29da1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -386,7 +391,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +401,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,7 +412,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -416,12 +420,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -432,14 +435,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -449,11 +452,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 @@ -465,10 +468,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -505,7 +504,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -517,7 +515,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -540,14 +538,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -559,7 +556,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -579,21 +576,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,7 +609,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -626,16 +619,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -655,10 +647,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -690,7 +678,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -702,7 +689,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -723,11 +710,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -739,7 +725,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -757,18 +743,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,7 +773,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -800,16 +782,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -821,13 +802,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -859,12 +836,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +854,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -886,16 +862,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -907,13 +882,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -949,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -968,7 +938,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -976,16 +946,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -995,11 +964,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1031,7 +996,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1043,7 +1007,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1063,11 +1027,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1079,7 +1042,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1096,17 +1059,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1129,7 +1088,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1138,16 +1097,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1157,11 +1115,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1198,7 +1152,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1211,7 +1164,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1235,11 +1188,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1252,7 +1204,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1273,18 +1225,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1310,7 +1258,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1320,16 +1268,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1344,10 +1291,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py index bc7a39440214..a5150ccb44d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -272,7 +277,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUser] :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +287,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,17 +298,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -315,14 +318,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -332,11 +335,11 @@ def extract_data(pipeline_response): 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 @@ -349,10 +352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -367,12 +366,11 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,22 +384,21 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,13 +411,9 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -450,7 +443,6 @@ def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -480,11 +472,10 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +487,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -512,17 +503,13 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -545,7 +532,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -554,16 +541,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -576,13 +562,9 @@ def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -600,12 +582,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,22 +600,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -645,11 +625,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_keys( @@ -667,12 +643,11 @@ def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -686,22 +661,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +688,9 @@ def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace def regenerate_password( @@ -738,12 +708,11 @@ def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,22 +726,21 @@ def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -785,10 +753,6 @@ def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py index 504d9b031f9d..3cf3485ef2c2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py index c483db27f34f..d8a7f992fac5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +330,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,13 +357,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +424,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +439,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -466,17 +457,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +487,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -508,16 +496,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,13 +517,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -556,12 +539,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +557,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,8 +582,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py index 3379e8b49d3b..4ad3304f8b20 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py index 3e4beb8d0ea9..0e2d96ed4a36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2021_09_01.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.storage.v2021_09_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py index c3e1e1a8a3b7..0bf85a44dfdb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2021_09_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py index dc436fd28e8e..10ce809484c5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py index c6685cd0451f..33f4e71e780a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py index 86fdc8c75b3d..8fc4602cd48e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py index 042219257f05..112c1a494053 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -441,7 +441,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request( +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -475,7 +475,7 @@ def build_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request( +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -544,7 +544,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -609,7 +609,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -617,18 +616,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -636,25 +634,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +672,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -704,22 +698,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,7 +732,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -750,16 +740,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -773,13 +762,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -808,14 +793,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] @@ -827,7 +804,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -845,18 +822,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] @@ -868,7 +837,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -884,19 +853,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] @@ -928,7 +887,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -938,17 +897,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -963,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,21 +938,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1006,11 +961,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -1036,12 +987,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_09_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1055,22 +1005,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1082,13 +1031,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1121,7 +1066,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1132,7 +1076,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1154,11 +1098,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1169,7 +1112,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1189,17 +1132,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1222,7 +1162,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1230,16 +1170,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,20 +1190,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1275,7 +1209,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1286,15 +1220,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1305,14 +1238,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1322,11 +1255,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 @@ -1338,8 +1271,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1348,7 +1279,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1359,7 +1289,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1370,16 +1300,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1390,14 +1319,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1407,11 +1336,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 @@ -1423,10 +1352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1444,12 +1369,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1463,22 +1387,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1490,13 +1413,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1524,7 +1443,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1453,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1551,11 +1469,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1483,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1579,18 +1496,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1613,7 +1527,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1621,16 +1535,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1555,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1675,7 +1584,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1686,7 +1594,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1702,11 +1610,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1717,7 +1624,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1730,17 +1637,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1763,7 +1666,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1771,16 +1674,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1792,13 +1694,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1824,7 +1722,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1835,7 +1732,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1850,11 +1747,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1865,7 +1761,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1878,17 +1774,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1911,7 +1803,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1919,16 +1811,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1940,18 +1831,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1965,21 +1852,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1989,11 +1875,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -2008,14 +1890,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2042,7 +1916,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -2053,22 +1927,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2082,22 +1952,21 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2108,11 +1977,7 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_hierarchical_namespace_migration( @@ -2132,14 +1997,6 @@ def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2167,7 +2024,7 @@ def begin_hierarchical_namespace_migration( 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( @@ -2178,22 +2035,18 @@ 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_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2207,21 +2060,20 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2232,14 +2084,10 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -2251,14 +2099,6 @@ def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2285,7 +2125,7 @@ def begin_abort_hierarchical_namespace_migration( 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( @@ -2296,26 +2136,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2338,7 +2174,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2346,16 +2182,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2375,10 +2210,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2403,14 +2234,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] @@ -2422,7 +2245,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2437,18 +2260,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] @@ -2460,7 +2275,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2473,19 +2288,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] @@ -2517,7 +2321,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2529,17 +2333,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2554,12 +2356,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2573,21 +2374,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2597,8 +2397,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py index 91a77be2ecfe..56741a11ca37 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -267,7 +272,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -279,7 +283,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -298,11 +302,10 @@ def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -314,7 +317,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -330,18 +333,14 @@ def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +366,7 @@ def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -376,16 +375,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +395,9 @@ def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload def update( @@ -434,7 +428,6 @@ def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +439,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -465,11 +458,10 @@ def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -481,7 +473,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -497,18 +489,14 @@ def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -534,7 +522,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -543,16 +531,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -564,13 +551,9 @@ def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -587,12 +570,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,22 +588,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,13 +614,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -658,12 +635,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +653,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +677,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -719,7 +690,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -730,7 +700,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -741,17 +711,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -762,14 +731,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -779,11 +748,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 @@ -794,7 +763,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py index 3a68d4b7a82b..9816b0dd3178 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py index 40770cbb74a6..5e4e909bde19 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py index ee6ac89b3804..f9bfd4854fd0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json index a82b8ebdf9e9..853cb69db687 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py index 3d43b979b6c3..cdeb4bbef0b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -172,7 +192,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") - 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 @@ -192,7 +212,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py index 200382867292..bc246da8db27 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py index 11f3f3e506df..990dfb884a7d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -118,7 +120,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -175,7 +195,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") - 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 @@ -195,7 +217,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py index 460c9b42c338..ad39f21eb91d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2022_05_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItem] @@ -118,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -137,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -153,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -170,11 +168,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 @@ -186,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -222,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -292,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -334,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -398,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -431,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -466,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -508,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -555,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -709,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -743,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -759,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -779,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -821,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -881,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -914,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -930,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -949,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -991,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1012,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1057,11 +995,6 @@ async def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1074,7 +1007,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1100,15 +1033,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1121,7 +1049,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1144,21 +1072,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,7 +1105,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1196,16 +1116,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1220,13 +1139,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1256,16 +1171,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1280,7 +1190,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1288,16 +1198,15 @@ async def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,13 +1221,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1345,16 +1250,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1369,7 +1269,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1377,16 +1277,15 @@ async def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1401,13 +1300,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1432,12 +1327,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,23 +1345,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,13 +1375,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1528,7 +1417,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1541,7 +1429,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1568,11 +1456,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1585,7 +1472,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1609,17 +1496,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1645,7 +1528,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1655,16 +1538,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1679,13 +1561,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1718,7 +1596,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1751,11 +1628,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,7 +1643,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1785,18 +1661,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,7 +1694,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1831,16 +1703,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1852,18 +1723,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,22 +1744,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,11 +1768,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1929,14 +1791,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1964,7 +1818,7 @@ async def begin_object_level_worm( 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( @@ -1975,14 +1829,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py index a569b9d28b2f..9cec7838b2cf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,13 +130,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -164,7 +163,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +174,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -195,11 +193,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -211,7 +208,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -228,17 +225,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,7 +254,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -270,16 +263,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,13 +283,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -320,12 +308,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,22 +326,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,11 +350,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -383,7 +365,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy] @@ -395,7 +376,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,17 +387,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -427,14 +407,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -444,11 +424,11 @@ async def extract_data(pipeline_response): 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 @@ -460,7 +440,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py index 29040e71cbdb..b02a03c8a40e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,10 +36,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -90,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -185,11 +179,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +189,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -217,15 +206,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -236,7 +220,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -251,21 +235,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +265,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -298,16 +274,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,13 +294,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -341,16 +312,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,22 +331,21 @@ async def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,10 +357,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py index ab5395593bba..f4b18001f4d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py index 0c6730660f3c..f1bd39ee6a26 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -497,7 +474,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScope] @@ -509,7 +485,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -520,17 +496,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -541,14 +516,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -558,11 +533,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 @@ -573,7 +548,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py index 1840f03ad419..f144691d10a1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -216,22 +200,14 @@ async def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py index 17b78431d350..3659cf6d0800 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -172,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -212,7 +211,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -224,7 +222,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -247,14 +245,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -286,21 +283,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +316,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +326,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +354,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +385,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +396,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +417,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +432,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +450,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +480,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +489,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +509,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +543,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +561,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +569,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +589,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +627,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +645,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -683,16 +653,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +671,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -738,7 +703,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -750,7 +714,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,11 +734,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -786,7 +749,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -803,17 +766,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +795,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -845,16 +804,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -864,11 +822,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -905,7 +859,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -918,7 +871,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -942,11 +895,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -959,7 +911,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -980,18 +932,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1017,7 +965,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1027,16 +975,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1051,10 +998,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py index 180a87d2676f..eeded3cc73cb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,6 +39,10 @@ build_regenerate_password_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]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUser] @@ -85,7 +89,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -169,12 +168,11 @@ async def get(self, resource_group_name: str, account_name: str, username: str, :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get(self, resource_group_name: str, account_name: str, username: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,13 +213,9 @@ async def get(self, resource_group_name: str, account_name: str, username: str, deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -252,7 +245,6 @@ async def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +256,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,11 +274,10 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +289,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -314,17 +305,13 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +334,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -356,16 +343,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,13 +364,9 @@ async def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -402,12 +384,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,22 +402,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -447,11 +427,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def list_keys( @@ -469,12 +445,11 @@ async def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,22 +463,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,13 +490,9 @@ async def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace_async async def regenerate_password( @@ -540,12 +510,11 @@ async def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,22 +528,21 @@ async def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -587,10 +555,6 @@ async def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py index 06e5ded03653..72e568d3a45c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py index 1bcfb0ebd2d1..64703fa14e5f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py index 606802deaf8b..47139c92d877 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py index 664eca82a2c9..1d18d641080d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.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.storage.v2022_05_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py index ab2b51cbccb1..064c39590706 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2022_05_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py index a87d566570e5..5e66d951b404 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py index 8664a771fec4..d1afb6fb371f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py index 653bfc90aa80..08e15f8e8d3d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py index a649556ba21c..738667fd1c8d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -51,10 +51,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +97,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -105,18 +104,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -124,25 +122,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -192,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,7 +220,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -238,16 +228,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,13 +250,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -296,14 +281,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -316,7 +293,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -334,18 +311,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -358,7 +327,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -374,19 +343,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -419,7 +378,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -429,17 +388,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -454,12 +411,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,21 +429,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,11 +452,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -527,12 +478,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2022_05_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,22 +496,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,13 +522,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -612,7 +557,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -623,7 +567,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -645,11 +589,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -660,7 +603,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -680,17 +623,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,7 +653,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -721,16 +661,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,20 +681,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] @@ -767,7 +701,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,15 +712,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -797,14 +730,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -814,11 +747,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 @@ -830,8 +763,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -842,7 +773,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] @@ -854,7 +784,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,16 +795,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -885,14 +814,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -902,11 +831,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 @@ -918,10 +847,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -939,12 +864,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,22 +882,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,13 +908,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1019,7 +938,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,7 +948,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1046,11 +964,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1061,7 +978,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1074,18 +991,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1108,7 +1022,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1116,16 +1030,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1137,13 +1050,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1170,7 +1079,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1181,7 +1089,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1197,11 +1105,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1119,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1225,17 +1132,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,7 +1161,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1266,16 +1169,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1287,13 +1189,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1319,7 +1217,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1330,7 +1227,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1345,11 +1242,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1360,7 +1256,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1373,17 +1269,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,7 +1298,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1414,16 +1306,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,18 +1326,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,21 +1347,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1484,11 +1370,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1503,14 +1385,6 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1537,7 +1411,7 @@ async def begin_failover(self, resource_group_name: str, account_name: str, **kw 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( @@ -1548,22 +1422,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1577,22 +1447,21 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1603,11 +1472,7 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_hierarchical_namespace_migration( @@ -1627,14 +1492,6 @@ async def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1662,7 +1519,7 @@ async def begin_hierarchical_namespace_migration( 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( @@ -1673,22 +1530,18 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } - - async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1702,21 +1555,20 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1727,14 +1579,10 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -1746,14 +1594,6 @@ async def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1780,7 +1620,7 @@ async def begin_abort_hierarchical_namespace_migration( 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( @@ -1791,26 +1631,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1833,7 +1669,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1841,16 +1677,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1870,10 +1705,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1898,14 +1729,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1918,7 +1741,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1933,18 +1756,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1957,7 +1772,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1970,19 +1785,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2015,7 +1819,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2027,17 +1831,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2052,12 +1854,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2071,21 +1872,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2095,8 +1895,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py index 875652b2f200..15059014d8c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -90,7 +95,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -102,7 +106,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -121,11 +125,10 @@ async def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -137,7 +140,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -153,18 +156,14 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload async def update( @@ -257,7 +251,6 @@ async def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +262,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -288,11 +281,10 @@ async def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +296,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -320,18 +312,14 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -410,12 +393,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,22 +411,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,13 +437,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -481,12 +458,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,22 +476,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,11 +500,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -542,7 +513,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,7 +523,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,17 +534,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -585,14 +554,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -602,11 +571,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 @@ -617,7 +586,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py index 107fc3d08682..f9c294c07f01 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py index be2b5b03e5d7..dda5586e6d9d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py index 1f268ecdcdbe..6676e407cce5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -128,7 +122,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -230,7 +224,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -318,7 +312,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. Ex - - /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 @@ -353,7 +347,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -387,7 +381,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Note that this enum may be extended in the future. Required. Known values are: "None", "AADDS", "AD", and "AADKERB". @@ -452,7 +446,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -626,7 +620,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -673,7 +667,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyFilter @@ -868,7 +862,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -929,7 +923,7 @@ class BlobInventoryPolicySchema(_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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -984,7 +978,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -1019,7 +1013,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -1119,7 +1113,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1369,7 +1363,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1464,7 +1458,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1500,7 +1494,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define snapshot and version action conditions. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1621,7 +1615,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. Ex - - /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 @@ -1630,22 +1624,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1653,7 +1631,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1737,7 +1715,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1949,7 +1927,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2376,7 +2354,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2448,7 +2426,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2606,7 +2584,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2835,7 +2813,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2895,7 +2873,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3149,7 +3127,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -3211,7 +3189,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3301,7 +3279,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3361,10 +3339,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequestEnum :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3403,7 +3381,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequestEnum :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3458,10 +3436,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3500,7 +3478,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3557,7 +3535,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3704,7 +3682,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3908,7 +3886,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4072,7 +4050,7 @@ class LocalUser(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4241,7 +4219,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4377,7 +4355,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyAction @@ -4416,7 +4394,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4465,7 +4443,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4522,7 +4500,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4739,7 +4717,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -4832,7 +4810,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4935,7 +4913,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -5103,7 +5081,7 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg class PermissionScope(_serialization.Model): """PermissionScope. - 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 permissions: The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c). Required. @@ -5173,7 +5151,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5258,7 +5236,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. Ex - - /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 @@ -5427,7 +5405,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5495,7 +5473,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5628,7 +5606,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5667,7 +5645,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -5890,7 +5868,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5960,7 +5938,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -6127,10 +6105,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. Ex - - /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 @@ -6175,10 +6153,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -6555,12 +6533,12 @@ def __init__( # pylint: disable=too-many-locals self.dns_endpoint_type = dns_endpoint_type -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -6593,7 +6571,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku @@ -7086,7 +7064,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -7436,7 +7414,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7569,7 +7547,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7613,7 +7591,7 @@ def __init__( class TableAccessPolicy(_serialization.Model): """Table Access Policy Properties Object. - 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 start_time: Start time of the access policy. :vartype start_time: ~datetime.datetime @@ -7663,7 +7641,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7703,7 +7681,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TableSignedIdentifier(_serialization.Model): """Object to set Table Access Policy. - 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: unique-64-character-value of the stored access policy. Required. :vartype id: str @@ -7741,7 +7719,7 @@ def __init__( class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -8031,10 +8009,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -8064,7 +8042,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py index 3c9ba4b4feed..d93e08dd22d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py @@ -292,7 +292,6 @@ class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -312,7 +311,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py index b91670d40425..8bdad8379973 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -300,7 +300,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -639,7 +639,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2022_05_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +649,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -661,7 +660,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -669,12 +668,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -685,14 +683,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -702,11 +700,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 @@ -718,10 +716,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -754,7 +748,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -766,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,11 +781,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -804,7 +796,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -824,17 +816,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +845,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -866,16 +854,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -895,10 +882,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -930,7 +913,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -942,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -963,11 +945,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -979,7 +960,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -998,17 +979,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1031,7 +1008,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1040,16 +1017,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1061,13 +1037,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1087,12 +1059,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,22 +1077,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,13 +1103,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1159,12 +1125,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1178,22 +1143,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1203,11 +1167,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1241,7 +1201,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1253,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1275,11 +1234,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1291,7 +1249,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1311,17 +1269,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1344,7 +1298,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1353,16 +1307,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1374,13 +1327,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1413,7 +1362,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1425,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1446,11 +1394,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1462,7 +1409,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1481,17 +1428,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1514,7 +1457,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1523,16 +1466,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1544,13 +1486,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1589,11 +1527,6 @@ def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1606,7 +1539,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1632,15 +1565,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1653,7 +1581,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1676,21 +1604,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1717,7 +1637,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1728,16 +1648,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1752,13 +1671,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1788,16 +1703,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1812,7 +1722,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1820,16 +1730,15 @@ def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1844,13 +1753,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1877,16 +1782,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1901,7 +1801,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1909,16 +1809,15 @@ def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1933,13 +1832,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1964,12 +1859,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1983,23 +1877,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2014,13 +1907,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2060,7 +1949,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2073,7 +1961,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2100,11 +1988,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2117,7 +2004,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2141,17 +2028,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2177,7 +2060,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2187,16 +2070,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2211,13 +2093,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2250,7 +2128,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2262,7 +2139,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2283,11 +2160,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2299,7 +2175,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2317,18 +2193,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2354,7 +2226,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2363,16 +2235,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2384,18 +2255,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2409,22 +2276,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2434,11 +2300,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2461,14 +2323,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2496,7 +2350,7 @@ def begin_object_level_worm( 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( @@ -2507,14 +2361,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py index 564a13fc6cdc..fb62d33ea7aa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -272,13 +275,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -309,7 +308,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -321,7 +319,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -340,11 +338,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -356,7 +353,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -373,17 +370,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,7 +399,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -415,16 +408,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,13 +428,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -465,12 +453,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,22 +471,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -509,11 +495,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -528,7 +510,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy] @@ -540,7 +521,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,17 +532,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -572,14 +552,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -589,11 +569,11 @@ def extract_data(pipeline_response): 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 @@ -605,7 +585,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py index 6c60a3d8abc5..768c8f2a49b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -179,7 +179,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -192,7 +191,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,17 +202,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -224,14 +222,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -241,11 +239,11 @@ def extract_data(pipeline_response): 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 @@ -257,10 +255,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -287,11 +281,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +291,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -319,15 +308,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +322,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -353,21 +337,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +367,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -400,16 +376,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +396,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -443,16 +414,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,22 +433,21 @@ def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,10 +459,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py index cafb321926d0..793bfce70601 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py index 0c6319030bdf..a693046c4031 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -235,7 +240,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +251,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,11 +274,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +289,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -306,17 +309,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,7 +338,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -348,16 +347,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,10 +376,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -413,7 +407,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +418,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -446,11 +439,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -481,17 +473,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +502,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -523,16 +511,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,13 +532,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -571,12 +554,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,22 +572,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,13 +599,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: @@ -637,7 +614,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +624,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,17 +635,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +655,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -697,11 +672,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 @@ -712,7 +687,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py index 358cc08fea60..4a234f3fb28e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -319,22 +303,14 @@ def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py index e09b9ebd737c..81509f7acb12 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -386,7 +391,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +401,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,7 +412,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -416,12 +420,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -432,14 +435,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -449,11 +452,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 @@ -465,10 +468,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -505,7 +504,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -517,7 +515,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -540,14 +538,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -559,7 +556,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -579,21 +576,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,7 +609,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -626,16 +619,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -655,10 +647,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -690,7 +678,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -702,7 +689,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -723,11 +710,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -739,7 +725,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -757,18 +743,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,7 +773,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -800,16 +782,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -821,13 +802,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -859,12 +836,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +854,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -886,16 +862,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -907,13 +882,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -949,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -968,7 +938,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -976,16 +946,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -995,11 +964,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1031,7 +996,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1043,7 +1007,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1063,11 +1027,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1079,7 +1042,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1096,17 +1059,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1129,7 +1088,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1138,16 +1097,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1157,11 +1115,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1198,7 +1152,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1211,7 +1164,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1235,11 +1188,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1252,7 +1204,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1273,18 +1225,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1310,7 +1258,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1320,16 +1268,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1344,10 +1291,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py index 2d196ab9bae3..6a1eb2d305c5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -272,7 +277,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUser] :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +287,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,17 +298,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -315,14 +318,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -332,11 +335,11 @@ def extract_data(pipeline_response): 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 @@ -349,10 +352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -367,12 +366,11 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,22 +384,21 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,13 +411,9 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -450,7 +443,6 @@ def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -480,11 +472,10 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +487,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -512,17 +503,13 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -545,7 +532,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -554,16 +541,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -576,13 +562,9 @@ def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -600,12 +582,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,22 +600,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -645,11 +625,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_keys( @@ -667,12 +643,11 @@ def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -686,22 +661,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +688,9 @@ def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace def regenerate_password( @@ -738,12 +708,11 @@ def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,22 +726,21 @@ def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -785,10 +753,6 @@ def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py index a44f78a2967a..0db22cc87ce9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py index 98420d71ec1e..cf56b4ded764 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +330,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,13 +357,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +424,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +439,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -466,17 +457,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +487,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -508,16 +496,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,13 +517,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -556,12 +539,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +557,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,8 +582,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py index 916b965296e2..69bd85c2d459 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py index ff5bd177567f..aa88a9ff3b4e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_05_01.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.storage.v2022_05_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py index 3cb8204f3ec4..4a0f3a0a27cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2022_05_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py index f55e171e8b69..387d49ea5472 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py index fb817d76e198..50bff0091287 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py index 8c8bf5e446c6..41e93c27fed0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py index 3bba7120b87b..88d17fc28878 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -441,7 +441,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request( +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -475,7 +475,7 @@ def build_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request( +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -544,7 +544,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -609,7 +609,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -617,18 +616,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -636,25 +634,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +672,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -704,22 +698,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,7 +732,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -750,16 +740,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -773,13 +762,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -808,14 +793,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] @@ -827,7 +804,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -845,18 +822,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] @@ -868,7 +837,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -884,19 +853,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] @@ -928,7 +887,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -938,17 +897,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -963,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,21 +938,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1006,11 +961,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -1036,12 +987,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2022_05_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1055,22 +1005,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1082,13 +1031,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1121,7 +1066,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1132,7 +1076,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1154,11 +1098,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1169,7 +1112,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1189,17 +1132,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1222,7 +1162,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1230,16 +1170,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,20 +1190,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1275,7 +1209,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1286,15 +1220,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1305,14 +1238,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1322,11 +1255,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 @@ -1338,8 +1271,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1348,7 +1279,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1359,7 +1289,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1370,16 +1300,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1390,14 +1319,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1407,11 +1336,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 @@ -1423,10 +1352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1444,12 +1369,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1463,22 +1387,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1490,13 +1413,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1524,7 +1443,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1535,7 +1453,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1551,11 +1469,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1566,7 +1483,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1579,18 +1496,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1613,7 +1527,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1621,16 +1535,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1642,13 +1555,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1675,7 +1584,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1686,7 +1594,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1702,11 +1610,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1717,7 +1624,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1730,17 +1637,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1763,7 +1666,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1771,16 +1674,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1792,13 +1694,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1824,7 +1722,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1835,7 +1732,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1850,11 +1747,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1865,7 +1761,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1878,17 +1774,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1911,7 +1803,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1919,16 +1811,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1940,18 +1831,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1965,21 +1852,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1989,11 +1875,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -2008,14 +1890,6 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2042,7 +1916,7 @@ def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: 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( @@ -2053,22 +1927,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2082,22 +1952,21 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2108,11 +1977,7 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_hierarchical_namespace_migration( @@ -2132,14 +1997,6 @@ def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2167,7 +2024,7 @@ def begin_hierarchical_namespace_migration( 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( @@ -2178,22 +2035,18 @@ 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_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2207,21 +2060,20 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2232,14 +2084,10 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -2251,14 +2099,6 @@ def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2285,7 +2125,7 @@ def begin_abort_hierarchical_namespace_migration( 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( @@ -2296,26 +2136,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2338,7 +2174,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2346,16 +2182,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2375,10 +2210,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2403,14 +2234,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] @@ -2422,7 +2245,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2437,18 +2260,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] @@ -2460,7 +2275,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2473,19 +2288,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] @@ -2517,7 +2321,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2529,17 +2333,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2554,12 +2356,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2573,21 +2374,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2597,8 +2397,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py index f426c12b72f0..1d8aece03a71 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -267,7 +272,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -279,7 +283,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -298,11 +302,10 @@ def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -314,7 +317,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -330,18 +333,14 @@ def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +366,7 @@ def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -376,16 +375,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +395,9 @@ def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload def update( @@ -434,7 +428,6 @@ def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +439,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -465,11 +458,10 @@ def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -481,7 +473,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -497,18 +489,14 @@ def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -534,7 +522,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -543,16 +531,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -564,13 +551,9 @@ def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -587,12 +570,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,22 +588,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,13 +614,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -658,12 +635,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +653,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +677,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -719,7 +690,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -730,7 +700,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -741,17 +711,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -762,14 +731,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -779,11 +748,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 @@ -794,7 +763,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py index edb3ada7c7d6..21f1afb60297 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py index fdfddd42f102..386b96c60938 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py index 93dd15b29196..663c09473419 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-09-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json index 5e6d6f69729b..866808f02b2b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py index 6ce7acf4712f..15e6eaf7e927 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -172,7 +192,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2022-09-01") - 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 @@ -192,7 +212,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py index 3353aa7a7b2b..4c03fa880515 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-09-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py index 2db20d3b9db4..c4dc5717ca8c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -118,7 +120,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -175,7 +195,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2022-09-01") - 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 @@ -195,7 +217,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py index 4d1e3fe3b935..e69b535eeafd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListContainerItem] @@ -118,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -137,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -153,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -170,11 +168,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 @@ -186,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -222,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -292,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -334,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -398,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -431,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -466,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -508,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -555,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -709,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -743,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -759,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -779,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -821,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -881,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -914,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -930,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -949,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -991,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1012,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1057,11 +995,6 @@ async def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1074,7 +1007,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1100,15 +1033,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1121,7 +1049,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1144,21 +1072,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,7 +1105,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1196,16 +1116,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1220,13 +1139,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1256,16 +1171,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1280,7 +1190,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1288,16 +1198,15 @@ async def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,13 +1221,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1345,16 +1250,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1369,7 +1269,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1377,16 +1277,15 @@ async def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1401,13 +1300,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1432,12 +1327,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,23 +1345,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,13 +1375,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1528,7 +1417,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1541,7 +1429,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1568,11 +1456,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1585,7 +1472,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1609,17 +1496,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1645,7 +1528,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1655,16 +1538,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1679,13 +1561,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1718,7 +1596,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1751,11 +1628,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,7 +1643,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1785,18 +1661,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,7 +1694,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1831,16 +1703,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1852,18 +1723,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,22 +1744,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,11 +1768,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1929,14 +1791,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1964,7 +1818,7 @@ async def begin_object_level_worm( 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( @@ -1975,14 +1829,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py index d405532537ed..17831ebf898e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,13 +130,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -164,7 +163,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +174,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -195,11 +193,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -211,7 +208,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -228,17 +225,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,7 +254,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -270,16 +263,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,13 +283,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -320,12 +308,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,22 +326,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,11 +350,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -383,7 +365,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy] @@ -395,7 +376,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,17 +387,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -427,14 +407,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -444,11 +424,11 @@ async def extract_data(pipeline_response): 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 @@ -460,7 +440,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py index f9da399a2652..5f65efc5f746 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,10 +36,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -90,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -185,11 +179,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +189,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -217,15 +206,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -236,7 +220,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -251,21 +235,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +265,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -298,16 +274,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,13 +294,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -341,16 +312,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,22 +331,21 @@ async def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,10 +357,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py index f131c41791e2..2b0e47640500 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py index 01406a57c4db..caac59cc09f4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -512,7 +489,6 @@ def list( :param include: Optional, when specified, will list encryption scopes with the specific state. Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListEncryptionScopesInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.EncryptionScope] @@ -524,7 +500,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -535,7 +511,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -543,12 +519,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +534,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -576,11 +551,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 @@ -591,7 +566,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py index b85fbe048423..6ce13d5a6331 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -216,22 +200,14 @@ async def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py index 8f7373c351ad..09dc046a559a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -172,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -212,7 +211,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -224,7 +222,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -247,14 +245,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -286,21 +283,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +316,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +326,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +354,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +385,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +396,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +417,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +432,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +450,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +480,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +489,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +509,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +543,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +561,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +569,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +589,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +627,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +645,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -683,16 +653,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +671,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -738,7 +703,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -750,7 +714,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,11 +734,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -786,7 +749,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -803,17 +766,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +795,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -845,16 +804,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -864,11 +822,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -905,7 +859,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -918,7 +871,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -942,11 +895,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -959,7 +911,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -980,18 +932,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1017,7 +965,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1027,16 +975,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1051,10 +998,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py index a7883540c538..524e4a9928eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,6 +39,10 @@ build_regenerate_password_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]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.LocalUser] @@ -85,7 +89,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -169,12 +168,11 @@ async def get(self, resource_group_name: str, account_name: str, username: str, :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get(self, resource_group_name: str, account_name: str, username: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,13 +213,9 @@ async def get(self, resource_group_name: str, account_name: str, username: str, deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -252,7 +245,6 @@ async def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +256,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,11 +274,10 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +289,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -314,17 +305,13 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +334,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -356,16 +343,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,13 +364,9 @@ async def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -402,12 +384,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,22 +402,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -447,11 +427,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def list_keys( @@ -469,12 +445,11 @@ async def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,22 +463,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,13 +490,9 @@ async def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace_async async def regenerate_password( @@ -540,12 +510,11 @@ async def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,22 +528,21 @@ async def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -587,10 +555,6 @@ async def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py index 50d37fb8dc5e..0afaffcc28a4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py index c4c082d4f5bd..5810275783fe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py index 5d49fef50c18..f56ed4728f31 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py index eef64036e580..224adfe0469c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.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.storage.v2022_09_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py index 1c111192e109..df68dbf3f592 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2022_09_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py index b009d85929c5..f390424dd011 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py index e8baaab80279..4712ca208346 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py index e0ec64756910..c3f028152658 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py index d1093de249cf..8a09b77ceae7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -51,10 +51,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +97,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -105,18 +104,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -124,25 +122,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,22 +160,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -192,22 +186,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,7 +220,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -238,16 +228,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,13 +250,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -296,14 +281,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -316,7 +293,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -334,18 +311,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -358,7 +327,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -374,19 +343,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -419,7 +378,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -429,17 +388,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -454,12 +411,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,21 +429,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,11 +452,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -527,12 +478,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2022_09_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,22 +496,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,13 +522,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -612,7 +557,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -623,7 +567,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -645,11 +589,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -660,7 +603,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -680,17 +623,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -713,7 +653,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -721,16 +661,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -742,20 +681,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] @@ -767,7 +701,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -778,15 +712,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -797,14 +730,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -814,11 +747,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 @@ -830,8 +763,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -842,7 +773,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] @@ -854,7 +784,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,16 +795,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -885,14 +814,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -902,11 +831,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 @@ -918,10 +847,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -939,12 +864,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,22 +882,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,13 +908,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1019,7 +938,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,7 +948,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1046,11 +964,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1061,7 +978,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1074,18 +991,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1108,7 +1022,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1116,16 +1030,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1137,13 +1050,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1170,7 +1079,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1181,7 +1089,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1197,11 +1105,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1212,7 +1119,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1225,17 +1132,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,7 +1161,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1266,16 +1169,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1287,13 +1189,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1319,7 +1217,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1330,7 +1227,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1345,11 +1242,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1360,7 +1256,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1373,17 +1269,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,7 +1298,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1414,16 +1306,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1435,18 +1326,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,22 +1347,21 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, failover_type=failover_type, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1485,11 +1371,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover( @@ -1517,14 +1399,6 @@ async def begin_failover( :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover is requested. Known values are "Planned" and None. Default value is "Planned". :type failover_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1552,7 +1426,7 @@ async def begin_failover( 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( @@ -1563,22 +1437,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1592,22 +1462,21 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1618,11 +1487,7 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_hierarchical_namespace_migration( @@ -1642,14 +1507,6 @@ async def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1677,7 +1534,7 @@ async def begin_hierarchical_namespace_migration( 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( @@ -1688,22 +1545,18 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } - - async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1717,21 +1570,20 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1742,14 +1594,10 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -1761,14 +1609,6 @@ async def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1795,7 +1635,7 @@ async def begin_abort_hierarchical_namespace_migration( 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( @@ -1806,26 +1646,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1848,7 +1684,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1856,16 +1692,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1885,10 +1720,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -1913,14 +1744,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1933,7 +1756,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1948,18 +1771,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -1972,7 +1787,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -1985,19 +1800,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2030,7 +1834,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2042,17 +1846,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2067,12 +1869,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2086,21 +1887,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2110,8 +1910,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py index 8756da44a9c3..83a71daa17d8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -90,7 +95,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -102,7 +106,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -121,11 +125,10 @@ async def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -137,7 +140,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -153,18 +156,14 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload async def update( @@ -257,7 +251,6 @@ async def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +262,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -288,11 +281,10 @@ async def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +296,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -320,18 +312,14 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -410,12 +393,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,22 +411,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,13 +437,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -481,12 +458,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,22 +476,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,11 +500,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -542,7 +513,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,7 +523,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,17 +534,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -585,14 +554,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -602,11 +571,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 @@ -617,7 +586,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py index fe966f75568a..0a5825a325b9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py index 6201a43e3946..6caeb1a5af5b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py index f7519f8c67fe..15ccd86cf684 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -128,7 +122,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -230,7 +224,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -318,7 +312,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. Ex - - /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 @@ -353,7 +347,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -387,7 +381,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Note that this enum may be extended in the future. Required. Known values are: "None", "AADDS", "AD", and "AADKERB". @@ -452,7 +446,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -626,7 +620,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -673,7 +667,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyFilter @@ -868,7 +862,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -929,7 +923,7 @@ class BlobInventoryPolicySchema(_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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -984,7 +978,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -1019,7 +1013,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -1119,7 +1113,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1369,7 +1363,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1464,7 +1458,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1500,7 +1494,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define snapshot and version action conditions. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1621,7 +1615,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. Ex - - /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 @@ -1630,22 +1624,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1653,7 +1631,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1737,7 +1715,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1949,7 +1927,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2376,7 +2354,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2448,7 +2426,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2606,7 +2584,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2835,7 +2813,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2895,7 +2873,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3149,7 +3127,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -3211,7 +3189,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3301,7 +3279,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3361,10 +3339,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequestEnum :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3403,7 +3381,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequestEnum :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3458,10 +3436,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3500,7 +3478,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3557,7 +3535,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3704,7 +3682,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3908,7 +3886,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4072,7 +4050,7 @@ class LocalUser(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4241,7 +4219,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4389,7 +4367,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyAction @@ -4428,7 +4406,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4477,7 +4455,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4534,7 +4512,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4775,7 +4753,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -4868,7 +4846,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4971,7 +4949,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -5139,7 +5117,7 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg class PermissionScope(_serialization.Model): """PermissionScope. - 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 permissions: The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c). Required. @@ -5209,7 +5187,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5294,7 +5272,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. Ex - - /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 @@ -5463,7 +5441,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5531,7 +5509,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5664,7 +5642,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5703,7 +5681,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -5926,7 +5904,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -5996,7 +5974,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -6163,10 +6141,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. Ex - - /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 @@ -6211,10 +6189,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -6591,12 +6569,12 @@ def __init__( # pylint: disable=too-many-locals self.dns_endpoint_type = dns_endpoint_type -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -6629,7 +6607,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku @@ -7122,7 +7100,7 @@ def __init__(self, **kwargs: Any) -> None: class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -7472,7 +7450,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7605,7 +7583,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7649,7 +7627,7 @@ def __init__( class TableAccessPolicy(_serialization.Model): """Table Access Policy Properties Object. - 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 start_time: Start time of the access policy. :vartype start_time: ~datetime.datetime @@ -7699,7 +7677,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7739,7 +7717,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TableSignedIdentifier(_serialization.Model): """Object to set Table Access Policy. - 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: unique-64-character-value of the stored access policy. Required. :vartype id: str @@ -7777,7 +7755,7 @@ def __init__( class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -8067,10 +8045,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -8100,7 +8078,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py index 2b474bb82436..05a30001df5c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py @@ -292,7 +292,6 @@ class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -312,7 +311,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py index a6ccda836450..75c73ec453bb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -300,7 +300,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -639,7 +639,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +649,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -661,7 +660,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -669,12 +668,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -685,14 +683,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -702,11 +700,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 @@ -718,10 +716,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -754,7 +748,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -766,7 +759,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,11 +781,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -804,7 +796,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -824,17 +816,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +845,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -866,16 +854,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -895,10 +882,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -930,7 +913,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -942,7 +924,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -963,11 +945,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -979,7 +960,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -998,17 +979,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1031,7 +1008,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1040,16 +1017,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1061,13 +1037,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1087,12 +1059,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1106,22 +1077,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,13 +1103,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1159,12 +1125,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1178,22 +1143,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1203,11 +1167,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1241,7 +1201,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1253,7 +1212,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1275,11 +1234,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1291,7 +1249,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1311,17 +1269,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1344,7 +1298,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1353,16 +1307,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1374,13 +1327,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1413,7 +1362,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1425,7 +1373,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1446,11 +1394,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1462,7 +1409,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1481,17 +1428,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1514,7 +1457,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1523,16 +1466,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1544,13 +1486,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1589,11 +1527,6 @@ def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1606,7 +1539,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1632,15 +1565,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1653,7 +1581,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1676,21 +1604,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1717,7 +1637,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1728,16 +1648,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1752,13 +1671,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1788,16 +1703,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1812,7 +1722,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1820,16 +1730,15 @@ def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1844,13 +1753,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1877,16 +1782,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1901,7 +1801,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1909,16 +1809,15 @@ def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1933,13 +1832,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1964,12 +1859,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1983,23 +1877,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2014,13 +1907,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2060,7 +1949,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2073,7 +1961,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2100,11 +1988,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2117,7 +2004,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2141,17 +2028,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2177,7 +2060,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2187,16 +2070,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2211,13 +2093,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2250,7 +2128,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2262,7 +2139,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2283,11 +2160,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2299,7 +2175,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2317,18 +2193,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2354,7 +2226,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2363,16 +2235,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2384,18 +2255,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2409,22 +2276,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2434,11 +2300,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2461,14 +2323,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2496,7 +2350,7 @@ def begin_object_level_worm( 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( @@ -2507,14 +2361,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py index 61290901d95e..1600eabec091 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -226,12 +231,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +249,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -272,13 +275,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -309,7 +308,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -321,7 +319,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -340,11 +338,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -356,7 +353,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -373,17 +370,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,7 +399,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -415,16 +408,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,13 +428,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -465,12 +453,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,22 +471,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -509,11 +495,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -528,7 +510,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy] @@ -540,7 +521,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,17 +532,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -572,14 +552,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -589,11 +569,11 @@ def extract_data(pipeline_response): 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 @@ -605,7 +585,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py index d61256cbc82c..2e773ea84b23 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -179,7 +179,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -192,7 +191,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,17 +202,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -224,14 +222,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -241,11 +239,11 @@ def extract_data(pipeline_response): 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 @@ -257,10 +255,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -287,11 +281,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +291,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -319,15 +308,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +322,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -353,21 +337,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,7 +367,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -400,16 +376,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,13 +396,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -443,16 +414,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,22 +433,21 @@ def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,10 +459,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py index 3ef5cef015fe..1eb70e4d45f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py index 38246c528d83..aeaf8d7fc2f7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -250,7 +255,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -262,7 +266,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -285,11 +289,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -301,7 +304,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -321,17 +324,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,7 +353,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -363,16 +362,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,10 +391,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -428,7 +422,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -440,7 +433,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -461,11 +454,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -477,7 +469,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -496,17 +488,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,7 +517,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -538,16 +526,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -560,13 +547,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -586,12 +569,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,22 +587,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,13 +614,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -669,7 +646,6 @@ def list( :param include: Optional, when specified, will list encryption scopes with the specific state. Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListEncryptionScopesInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -680,7 +656,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -691,7 +667,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -699,12 +675,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -715,14 +690,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -732,11 +707,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 @@ -747,7 +722,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py index 604392f73615..f352f4a97529 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -319,22 +303,14 @@ def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py index 2aa01633c0b1..9160249c81b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -386,7 +391,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +401,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,7 +412,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -416,12 +420,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -432,14 +435,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -449,11 +452,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 @@ -465,10 +468,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -505,7 +504,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -517,7 +515,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -540,14 +538,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -559,7 +556,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -579,21 +576,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,7 +609,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -626,16 +619,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -655,10 +647,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -690,7 +678,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -702,7 +689,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -723,11 +710,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -739,7 +725,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -757,18 +743,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,7 +773,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -800,16 +782,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -821,13 +802,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -859,12 +836,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +854,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -886,16 +862,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -907,13 +882,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -949,12 +920,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -968,7 +938,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -976,16 +946,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -995,11 +964,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1031,7 +996,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1043,7 +1007,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1063,11 +1027,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1079,7 +1042,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1096,17 +1059,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1129,7 +1088,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1138,16 +1097,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1157,11 +1115,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1198,7 +1152,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1211,7 +1164,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1235,11 +1188,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1252,7 +1204,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1273,18 +1225,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1310,7 +1258,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1320,16 +1268,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1344,10 +1291,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py index 1ccdb05acba2..c87ffc0778fc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -272,7 +277,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.LocalUser] :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +287,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,17 +298,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -315,14 +318,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -332,11 +335,11 @@ def extract_data(pipeline_response): 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 @@ -349,10 +352,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -367,12 +366,11 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,22 +384,21 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,13 +411,9 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -450,7 +443,6 @@ def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +454,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -480,11 +472,10 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +487,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -512,17 +503,13 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -545,7 +532,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -554,16 +541,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -576,13 +562,9 @@ def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -600,12 +582,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,22 +600,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -645,11 +625,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_keys( @@ -667,12 +643,11 @@ def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -686,22 +661,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +688,9 @@ def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace def regenerate_password( @@ -738,12 +708,11 @@ def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,22 +726,21 @@ def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -785,10 +753,6 @@ def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py index 07f1159d7828..08c55a2eae73 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -187,12 +192,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,22 +210,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +236,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -270,7 +269,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -282,7 +280,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +299,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +314,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -334,17 +331,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +360,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -376,16 +369,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +389,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -426,12 +414,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,22 +432,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +456,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py index ce9eeab3dadb..eacfc0817ecb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -212,7 +217,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -225,7 +229,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,17 +240,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -257,14 +260,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -274,11 +277,11 @@ def extract_data(pipeline_response): 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 @@ -291,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -313,12 +312,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +330,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,13 +357,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -399,7 +392,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +403,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -432,11 +424,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +439,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -466,17 +457,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +487,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -508,16 +496,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,13 +517,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -556,12 +539,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,22 +557,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,8 +582,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py index 0e3591edda68..a54571d70cb4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py index dc32614dbcd8..a6bcca87c0b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -224,7 +229,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -237,7 +241,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,17 +252,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,14 +272,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -286,11 +289,11 @@ def extract_data(pipeline_response): 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 @@ -302,10 +305,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -322,12 +321,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,22 +339,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +366,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -405,7 +398,6 @@ def put( :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.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -417,7 +409,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -435,11 +427,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +442,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -467,17 +458,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2022_09_01.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.storage.v2022_09_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +487,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,16 +496,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,13 +517,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -555,12 +537,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +555,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,8 +580,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py index bbbb81bbbea1..f8dfe3fadf52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -100,12 +105,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2022_09_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,21 +123,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,10 +148,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py index c1cff2001375..20739e8bfbf5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -300,7 +305,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -312,7 +316,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,11 +336,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -366,17 +369,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,7 +398,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -408,16 +407,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,13 +427,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -467,7 +461,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -479,7 +472,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -499,11 +492,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +507,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -533,17 +525,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +554,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -575,16 +563,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +583,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -620,12 +603,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,22 +621,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -666,13 +647,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -692,12 +669,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,22 +687,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -736,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -766,7 +737,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -777,7 +747,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,19 +758,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -811,14 +780,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -828,11 +797,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 @@ -843,7 +812,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py index 9843859045de..e934ba9fafa1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py index 73e0b763e3ad..ae4341f2b3af 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py index 34807c26106f..0f38de305e79 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -448,7 +448,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request( +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -482,7 +482,7 @@ def build_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request( +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -551,7 +551,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -616,7 +616,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -624,18 +623,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -643,25 +641,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -684,22 +679,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -711,22 +705,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -749,7 +739,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -757,16 +747,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -780,13 +769,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -815,14 +800,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] @@ -834,7 +811,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -852,18 +829,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] @@ -875,7 +844,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -891,19 +860,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] @@ -935,7 +894,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -945,17 +904,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -970,12 +927,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -989,21 +945,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1013,11 +968,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -1043,12 +994,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2022_09_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1062,22 +1012,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1089,13 +1038,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1128,7 +1073,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1139,7 +1083,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1161,11 +1105,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1176,7 +1119,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1196,17 +1139,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1229,7 +1169,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1237,16 +1177,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1258,20 +1197,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1282,7 +1216,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1293,15 +1227,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1312,14 +1245,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1329,11 +1262,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 @@ -1345,8 +1278,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1355,7 +1286,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1366,7 +1296,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1377,16 +1307,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1397,14 +1326,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1414,11 +1343,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 @@ -1430,10 +1359,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1451,12 +1376,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1470,22 +1394,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1497,13 +1420,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1531,7 +1450,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1542,7 +1460,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1558,11 +1476,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1573,7 +1490,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1586,18 +1503,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1620,7 +1534,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1628,16 +1542,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1649,13 +1562,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1682,7 +1591,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1693,7 +1601,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1709,11 +1617,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1724,7 +1631,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1737,17 +1644,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1770,7 +1673,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1778,16 +1681,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1799,13 +1701,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1831,7 +1729,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1842,7 +1739,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1857,11 +1754,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1872,7 +1768,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1885,17 +1781,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1918,7 +1810,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1926,16 +1818,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1947,18 +1838,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1972,22 +1859,21 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, failover_type=failover_type, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1997,11 +1883,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover( @@ -2029,14 +1911,6 @@ def begin_failover( :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover is requested. Known values are "Planned" and None. Default value is "Planned". :type failover_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2064,7 +1938,7 @@ def begin_failover( 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( @@ -2075,22 +1949,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2104,22 +1974,21 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2130,11 +1999,7 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_hierarchical_namespace_migration( @@ -2154,14 +2019,6 @@ def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2189,7 +2046,7 @@ def begin_hierarchical_namespace_migration( 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( @@ -2200,22 +2057,18 @@ 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_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2229,21 +2082,20 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2254,14 +2106,10 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -2273,14 +2121,6 @@ def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2307,7 +2147,7 @@ def begin_abort_hierarchical_namespace_migration( 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( @@ -2318,26 +2158,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2360,7 +2196,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2368,16 +2204,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2397,10 +2232,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2425,14 +2256,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] @@ -2444,7 +2267,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2459,18 +2282,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] @@ -2482,7 +2297,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2495,19 +2310,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] @@ -2539,7 +2343,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2551,17 +2355,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2576,12 +2378,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2595,21 +2396,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2619,8 +2419,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py index e43dffa496cb..2052cc10020d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -267,7 +272,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -279,7 +283,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -298,11 +302,10 @@ def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -314,7 +317,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -330,18 +333,14 @@ def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +366,7 @@ def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -376,16 +375,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +395,9 @@ def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload def update( @@ -434,7 +428,6 @@ def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +439,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -465,11 +458,10 @@ def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -481,7 +473,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -497,18 +489,14 @@ def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -534,7 +522,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -543,16 +531,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -564,13 +551,9 @@ def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -587,12 +570,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,22 +588,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,13 +614,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -658,12 +635,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,22 +653,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +677,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -719,7 +690,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -730,7 +700,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -741,17 +711,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -762,14 +731,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -779,11 +748,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 @@ -794,7 +763,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py index 2867eda371a3..2bd19f912f02 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,12 +175,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,21 +193,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -254,11 +248,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +258,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -286,15 +275,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +289,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -320,21 +304,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +334,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -367,16 +343,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -388,13 +363,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -410,16 +381,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +400,21 @@ def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,10 +426,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py index 483eeaccb6fd..b5c9e5fcb472 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_configuration.py index f002dd9f80ec..039fbf2b172c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2023-01-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_metadata.json index 5deb99b490b2..104502301b8d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_storage_management_client.py index 393e35bd313b..9df6c2ea2965 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 .._serialization import Deserializer, Serializer @@ -115,7 +117,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -172,7 +192,7 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2023-01-01") - 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 @@ -192,7 +212,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_version.py index a012ac01c480..da0ea07dff87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "21.1.0" +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_configuration.py index 8a4c8bfed645..ec66fb14632d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/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 StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(StorageManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2023-01-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,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/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_storage_management_client.py index 5f53f1feee24..b92ea86627c1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/_storage_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -118,7 +120,25 @@ def __init__( self._config = StorageManagementClientConfiguration( 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) @@ -175,7 +195,9 @@ def __init__( ) self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2023-01-01") - 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 @@ -195,7 +217,7 @@ 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() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_containers_operations.py index 9e5d7be15683..609bf13aeb4a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -49,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +106,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2023_01_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.ListContainerItem] @@ -118,7 +117,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +128,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -137,12 +136,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -153,14 +151,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -170,11 +168,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 @@ -186,10 +184,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload async def create( self, @@ -222,7 +216,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -234,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,11 +249,10 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -292,17 +284,13 @@ async def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,7 +313,7 @@ async def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -334,16 +322,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +350,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload async def update( self, @@ -398,7 +381,6 @@ async def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +392,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -431,11 +413,10 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +428,7 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -466,17 +447,13 @@ async def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,7 +476,7 @@ async def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -508,16 +485,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +505,9 @@ async def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -555,12 +527,11 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,22 +545,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,13 +571,9 @@ async def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -627,12 +593,11 @@ async def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,22 +611,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,11 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def set_legal_hold( @@ -709,7 +669,6 @@ async def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +680,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -743,11 +702,10 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -759,7 +717,7 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -779,17 +737,13 @@ async def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +766,7 @@ async def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -821,16 +775,15 @@ async def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,13 +795,9 @@ async def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload async def clear_legal_hold( @@ -881,7 +830,6 @@ async def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +841,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -914,11 +862,10 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -930,7 +877,7 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -949,17 +896,13 @@ async def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +925,7 @@ async def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -991,16 +934,15 @@ async def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1012,13 +954,9 @@ async def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload async def create_or_update_immutability_policy( @@ -1057,11 +995,6 @@ async def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1074,7 +1007,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1100,15 +1033,10 @@ async def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1121,7 +1049,7 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1144,21 +1072,13 @@ async def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1185,7 +1105,7 @@ async def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1196,16 +1116,15 @@ async def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1220,13 +1139,9 @@ async def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -1256,16 +1171,11 @@ async def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1280,7 +1190,7 @@ async def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1288,16 +1198,15 @@ async def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,13 +1221,9 @@ async def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -1345,16 +1250,11 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1369,7 +1269,7 @@ async def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1377,16 +1277,15 @@ async def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1401,13 +1300,9 @@ async def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def lock_immutability_policy( @@ -1432,12 +1327,11 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1451,23 +1345,22 @@ async def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1482,13 +1375,9 @@ async def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload async def extend_immutability_policy( @@ -1528,7 +1417,6 @@ async def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1541,7 +1429,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1568,11 +1456,10 @@ async def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1585,7 +1472,7 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1609,17 +1496,13 @@ async def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1645,7 +1528,7 @@ async def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1655,16 +1538,15 @@ async def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1679,13 +1561,9 @@ async def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload async def lease( @@ -1718,7 +1596,6 @@ async def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1730,7 +1607,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1751,11 +1628,10 @@ async def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1767,7 +1643,7 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -1785,18 +1661,14 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1822,7 +1694,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1831,16 +1703,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1852,18 +1723,14 @@ async def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,22 +1744,21 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,11 +1768,7 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_object_level_worm( @@ -1929,14 +1791,6 @@ async def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -1964,7 +1818,7 @@ async def begin_object_level_worm( 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( @@ -1975,14 +1829,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_inventory_policies_operations.py index fadf1c52a02f..e7b4a5128f2c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_inventory_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -81,12 +86,11 @@ async def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,22 +104,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,13 +130,9 @@ async def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -164,7 +163,6 @@ async def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +174,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -195,11 +193,10 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -211,7 +208,7 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -228,17 +225,13 @@ async def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,7 +254,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -270,16 +263,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,13 +283,9 @@ async def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -320,12 +308,11 @@ async def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,22 +326,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -364,11 +350,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -383,7 +365,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy] @@ -395,7 +376,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,17 +387,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -427,14 +407,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -444,11 +424,11 @@ async def extract_data(pipeline_response): 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 @@ -460,7 +440,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_services_operations.py index 406ca2451222..8e56182c22ce 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,10 +36,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +77,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -90,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,17 +100,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload async def set_service_properties( self, @@ -185,11 +179,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +189,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -217,15 +206,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -236,7 +220,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -251,21 +235,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +265,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -298,16 +274,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,13 +294,9 @@ async def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -341,16 +312,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,22 +331,21 @@ async def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,10 +357,6 @@ async def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_deleted_accounts_operations.py index 0d4ad307cb47..c6b0f623c4fe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_deleted_accounts_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,8 @@ # 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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, 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]] @@ -58,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.DeletedAccount] @@ -70,7 +74,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,15 +85,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -100,14 +103,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -117,11 +120,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 @@ -134,8 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace_async async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -144,12 +145,11 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -163,21 +163,20 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +189,6 @@ async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_encryption_scopes_operations.py index 83d409898918..ebabd468b62e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_encryption_scopes_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -93,7 +98,6 @@ async def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -128,11 +132,10 @@ async def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +147,7 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -164,17 +167,13 @@ async def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -197,7 +196,7 @@ async def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -206,16 +205,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +234,6 @@ async def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload async def patch( self, @@ -271,7 +265,6 @@ async def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +276,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -304,11 +297,10 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +312,7 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -339,17 +331,13 @@ async def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,7 +360,7 @@ async def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -381,16 +369,15 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +390,9 @@ async def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -429,12 +412,11 @@ async def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,22 +430,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,13 +457,9 @@ async def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -512,7 +489,6 @@ def list( :param include: Optional, when specified, will list encryption scopes with the specific state. Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. :type include: str or ~azure.mgmt.storage.v2023_01_01.models.ListEncryptionScopesInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.EncryptionScope] @@ -524,7 +500,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -535,7 +511,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -543,12 +519,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,14 +534,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -576,11 +551,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 @@ -591,7 +566,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_services_operations.py index 605ed8b4d270..ec0d02d3c212 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -216,22 +200,14 @@ async def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_shares_operations.py index 1b6fe14f6cce..3df4714f2ab4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_file_shares_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,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]] @@ -92,7 +97,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.FileShareItem] @@ -104,7 +108,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +119,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -123,12 +127,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,14 +142,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -156,11 +159,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 @@ -172,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload async def create( self, @@ -212,7 +211,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -224,7 +222,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -247,14 +245,13 @@ async def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +263,7 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -286,21 +283,17 @@ async def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +316,7 @@ async def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -333,16 +326,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,10 +354,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload async def update( self, @@ -397,7 +385,6 @@ async def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -409,7 +396,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -430,11 +417,10 @@ async def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -446,7 +432,7 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -464,18 +450,14 @@ async def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +480,7 @@ async def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -507,16 +489,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,13 +509,9 @@ async def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -566,12 +543,11 @@ async def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +561,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -593,16 +569,15 @@ async def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -614,13 +589,9 @@ async def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -656,12 +627,11 @@ async def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,7 +645,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -683,16 +653,15 @@ async def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +671,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def restore( # pylint: disable=inconsistent-return-statements @@ -738,7 +703,6 @@ async def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -750,7 +714,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,11 +734,10 @@ async def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -786,7 +749,7 @@ async def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -803,17 +766,13 @@ async def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2023_01_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2023_01_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +795,7 @@ async def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -845,16 +804,15 @@ async def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -864,11 +822,7 @@ async def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def lease( @@ -905,7 +859,6 @@ async def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -918,7 +871,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -942,11 +895,10 @@ async def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -959,7 +911,7 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -980,18 +932,14 @@ async def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1017,7 +965,7 @@ async def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1027,16 +975,15 @@ async def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1051,10 +998,6 @@ async def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_local_users_operations.py index 465b2caee047..9247f364aa52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_local_users_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,6 +39,10 @@ build_regenerate_password_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]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.LocalUser] @@ -85,7 +89,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,14 +120,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -169,12 +168,11 @@ async def get(self, resource_group_name: str, account_name: str, username: str, :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get(self, resource_group_name: str, account_name: str, username: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,13 +213,9 @@ async def get(self, resource_group_name: str, account_name: str, username: str, deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -252,7 +245,6 @@ async def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -264,7 +256,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,11 +274,10 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +289,7 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -314,17 +305,13 @@ async def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,7 +334,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -356,16 +343,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,13 +364,9 @@ async def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -402,12 +384,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,22 +402,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -447,11 +427,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def list_keys( @@ -469,12 +445,11 @@ async def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,22 +463,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,13 +490,9 @@ async def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace_async async def regenerate_password( @@ -540,12 +510,11 @@ async def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,22 +528,21 @@ async def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -587,10 +555,6 @@ async def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_management_policies_operations.py index 865010016d0d..85238c6c925d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,10 @@ 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]] @@ -77,12 +82,11 @@ async def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,22 +100,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +126,9 @@ async def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -160,7 +159,6 @@ async def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +170,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -191,11 +189,10 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -207,7 +204,7 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -224,17 +221,13 @@ async def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,7 +250,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -266,16 +259,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,13 +279,9 @@ async def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -316,12 +304,11 @@ async def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,22 +322,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +346,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_object_replication_policies_operations.py index ab15368deca9..0bfccfc3eb83 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_object_replication_policies_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ 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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -152,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -174,12 +173,11 @@ async def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,22 +191,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +218,9 @@ async def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -260,7 +253,6 @@ async def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -272,7 +264,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +285,10 @@ async def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +300,7 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -327,17 +318,14 @@ async def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +348,7 @@ async def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -369,16 +357,15 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,13 +378,9 @@ async def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -417,12 +400,11 @@ async def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,22 +418,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,8 +443,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_operations.py index 4b8b98b743ba..340332958f52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/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,8 @@ # 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 @@ -29,6 +30,10 @@ 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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.Operation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,14 +101,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): 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 @@ -130,5 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_private_endpoint_connections_operations.py index 732905456ed4..dc039cadea50 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/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. @@ -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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_put_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]] @@ -73,7 +78,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -86,7 +90,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +101,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,14 +121,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -135,11 +138,11 @@ async def extract_data(pipeline_response): 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 @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -171,12 +170,11 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,13 +215,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def put( @@ -254,7 +247,6 @@ async def put( :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.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +258,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -284,11 +276,10 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +291,7 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -316,17 +307,13 @@ async def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.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.storage.v2023_01_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,7 +336,7 @@ async def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -358,16 +345,15 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +366,9 @@ async def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -404,12 +386,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,22 +404,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,8 +429,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_private_link_resources_operations.py index 59c42f41c0e5..a53c1e3b2ba9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_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,12 +69,11 @@ async def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2023_01_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,21 +87,20 @@ async def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,10 +112,6 @@ async def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_operations.py index b7d45b0a8152..76048ac11b4a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -91,7 +96,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +107,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -123,11 +127,10 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -139,7 +142,7 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -157,17 +160,13 @@ async def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload async def update( @@ -258,7 +252,6 @@ async def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +263,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +283,10 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -306,7 +298,7 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -324,17 +316,13 @@ async def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -413,12 +396,11 @@ async def get( it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,22 +414,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,13 +440,9 @@ async def get( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -485,12 +462,11 @@ async def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,22 +480,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,11 +504,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -559,7 +530,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.ListQueue] @@ -571,7 +541,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,19 +552,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -605,14 +574,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -622,11 +591,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 @@ -637,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_services_operations.py index 87fdc67f2c66..86a21a059a17 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_skus_operations.py index e5f028204c1e..c3a1cda8c096 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_skus_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._skus_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]] @@ -57,7 +62,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.SkuInformation] @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,15 +84,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,14 +102,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -116,11 +119,11 @@ async def extract_data(pipeline_response): 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 @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_storage_accounts_operations.py index a06be5fa9c21..0ca5cfed9747 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -53,10 +53,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,7 +99,6 @@ async def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -107,18 +106,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -126,25 +124,22 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,22 +162,21 @@ async def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,22 +188,18 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -232,7 +222,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -240,16 +230,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -263,13 +252,9 @@ async def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -298,14 +283,6 @@ async def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: @@ -318,7 +295,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -336,18 +313,10 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: @@ -360,7 +329,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -376,19 +345,9 @@ async def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of cls(response) :rtype: @@ -421,7 +380,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -431,17 +390,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -456,12 +413,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -475,21 +431,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,11 +454,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_properties( @@ -529,12 +480,11 @@ async def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2023_01_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -548,22 +498,21 @@ async def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -575,13 +524,9 @@ async def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def update( @@ -614,7 +559,6 @@ async def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -625,7 +569,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -647,11 +591,10 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -662,7 +605,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -682,17 +625,14 @@ async def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +655,7 @@ async def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -723,16 +663,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -744,20 +683,15 @@ async def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] @@ -769,7 +703,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -780,15 +714,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -799,14 +732,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -816,11 +749,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 @@ -832,8 +765,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -844,7 +775,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] @@ -856,7 +786,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -867,16 +797,15 @@ 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -887,14 +816,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -904,11 +833,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 @@ -920,10 +849,6 @@ 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.Storage/storageAccounts" - } - @distributed_trace_async async def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -941,12 +866,11 @@ async def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -960,22 +884,21 @@ async def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -987,13 +910,9 @@ async def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload async def regenerate_key( @@ -1021,7 +940,6 @@ async def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1032,7 +950,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1048,11 +966,10 @@ async def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1063,7 +980,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1076,18 +993,15 @@ async def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2023_01_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2023_01_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1110,7 +1024,7 @@ async def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1118,16 +1032,15 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1139,13 +1052,9 @@ async def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload async def list_account_sas( @@ -1172,7 +1081,6 @@ async def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1183,7 +1091,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1199,11 +1107,10 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1214,7 +1121,7 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1227,17 +1134,13 @@ async def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1260,7 +1163,7 @@ async def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1268,16 +1171,15 @@ async def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1289,13 +1191,9 @@ async def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload async def list_service_sas( @@ -1321,7 +1219,6 @@ async def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1332,7 +1229,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1347,11 +1244,10 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1362,7 +1258,7 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1375,17 +1271,13 @@ async def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1408,7 +1300,7 @@ async def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1416,16 +1308,15 @@ async def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1437,18 +1328,14 @@ async def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1462,22 +1349,21 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, failover_type=failover_type, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1487,11 +1373,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_failover( @@ -1519,14 +1401,6 @@ async def begin_failover( :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover is requested. Known values are "Planned" and None. Default value is "Planned". :type failover_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1554,7 +1428,7 @@ async def begin_failover( 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( @@ -1565,22 +1439,18 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } - - async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1594,22 +1464,21 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1620,11 +1489,7 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_hierarchical_namespace_migration( @@ -1644,14 +1509,6 @@ async def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1679,7 +1536,7 @@ async def begin_hierarchical_namespace_migration( 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( @@ -1690,22 +1547,18 @@ 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_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1719,21 +1572,20 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1744,14 +1596,10 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -1763,14 +1611,6 @@ async def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -1797,7 +1637,7 @@ async def begin_abort_hierarchical_namespace_migration( 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( @@ -1808,26 +1648,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _customer_initiated_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountMigration, IO], + parameters: Union[_models.StorageAccountMigration, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1850,7 +1686,7 @@ async def _customer_initiated_migration_initial( # pylint: disable=inconsistent else: _json = self._serialize.body(parameters, "StorageAccountMigration") - request = build_customer_initiated_migration_request( + _request = build_customer_initiated_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1858,16 +1694,15 @@ async def _customer_initiated_migration_initial( # pylint: disable=inconsistent content_type=content_type, json=_json, content=_content, - template_url=self._customer_initiated_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1882,11 +1717,7 @@ async def _customer_initiated_migration_initial( # pylint: disable=inconsistent response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _customer_initiated_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/startAccountMigration" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload async def begin_customer_initiated_migration( @@ -1917,14 +1748,6 @@ async def begin_customer_initiated_migration( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1935,7 +1758,7 @@ async def begin_customer_initiated_migration( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1955,18 +1778,10 @@ async def begin_customer_initiated_migration( :type account_name: str :param parameters: The request parameters required to perform storage account migration. 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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1977,7 +1792,7 @@ async def begin_customer_initiated_migration( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountMigration, IO], + parameters: Union[_models.StorageAccountMigration, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Account Migration request can be triggered for a storage account to change its redundancy @@ -1994,19 +1809,8 @@ async def begin_customer_initiated_migration( lower-case letters only. Required. :type account_name: str :param parameters: The request parameters required to perform storage account migration. Is - either a StorageAccountMigration type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountMigration 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. + either a StorageAccountMigration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountMigration or IO[bytes] :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: @@ -2036,7 +1840,7 @@ async def begin_customer_initiated_migration( 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( @@ -2047,17 +1851,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_customer_initiated_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/startAccountMigration" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get_customer_initiated_migration( @@ -2079,12 +1879,11 @@ async def get_customer_initiated_migration( :param migration_name: The name of the Storage Account Migration. It should always be 'default'. "default" Required. :type migration_name: str or ~azure.mgmt.storage.v2023_01_01.models.MigrationName - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountMigration or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountMigration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2098,22 +1897,21 @@ async def get_customer_initiated_migration( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountMigration] = kwargs.pop("cls", None) - request = build_get_customer_initiated_migration_request( + _request = build_get_customer_initiated_migration_request( resource_group_name=resource_group_name, account_name=account_name, migration_name=migration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_customer_initiated_migration.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2126,22 +1924,18 @@ async def get_customer_initiated_migration( deserialized = self._deserialize("StorageAccountMigration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_customer_initiated_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/accountMigrations/{migrationName}" - } + return deserialized # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2164,7 +1958,7 @@ async def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2172,16 +1966,15 @@ async def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2201,10 +1994,6 @@ async def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload async def begin_restore_blob_ranges( self, @@ -2229,14 +2018,6 @@ async def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -2249,7 +2030,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2264,18 +2045,10 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: @@ -2288,7 +2061,7 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2301,19 +2074,8 @@ async def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: @@ -2346,7 +2108,7 @@ async def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2358,17 +2120,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2383,12 +2143,11 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2402,21 +2161,20 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2426,8 +2184,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_operations.py index b0ccc5dc3960..10b995ac5311 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_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, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -37,6 +38,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]] @@ -90,7 +95,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -102,7 +106,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -121,11 +125,10 @@ async def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -137,7 +140,7 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -153,18 +156,14 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +189,7 @@ async def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -199,16 +198,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +218,9 @@ async def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload async def update( @@ -257,7 +251,6 @@ async def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -269,7 +262,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -288,11 +281,10 @@ async def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +296,7 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -320,18 +312,14 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -357,7 +345,7 @@ async def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -366,16 +354,15 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,13 +374,9 @@ async def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -410,12 +393,11 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,22 +411,21 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,13 +437,9 @@ async def get(self, resource_group_name: str, account_name: str, table_name: str deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -481,12 +458,11 @@ async def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,22 +476,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,11 +500,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: @@ -542,7 +513,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,7 +523,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,17 +534,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -585,14 +554,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -602,11 +571,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 @@ -617,7 +586,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_services_operations.py index 2cf53cdaf6ec..e8562a94cca8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,10 +33,10 @@ build_set_service_properties_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +72,11 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +90,20 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,13 +115,9 @@ async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload async def set_service_properties( @@ -151,11 +145,6 @@ async def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +155,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -183,15 +172,10 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +186,7 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -217,21 +201,13 @@ async def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +231,7 @@ async def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -264,16 +240,15 @@ async def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +260,9 @@ async def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace_async async def get_service_properties( @@ -307,16 +278,11 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,22 +297,21 @@ async def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,10 +323,6 @@ async def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_usages_operations.py index debf466312b6..5ccb6b03a3e0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/aio/operations/_usages_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,8 @@ # 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 @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_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]] @@ -60,7 +65,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_01_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -71,7 +75,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,16 +86,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -102,14 +105,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -119,11 +122,11 @@ async def extract_data(pipeline_response): 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 @@ -134,7 +137,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_models_py3.py index bb58ede79b2d..64f527dc3fd2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_models_py3.py @@ -8,16 +8,10 @@ # -------------------------------------------------------------------------- import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -128,7 +122,7 @@ def __init__( class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. - 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 services: The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". @@ -230,7 +224,7 @@ def __init__( class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). - 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 domain_name: Specifies the primary domain that the AD DNS server is authoritative for. Required. @@ -318,7 +312,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. Ex - - /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 @@ -353,7 +347,7 @@ class AzureEntityResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -387,7 +381,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. - 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 directory_service_options: Indicates the directory service used. Note that this enum may be extended in the future. Required. Known values are: "None", "AADDS", "AD", and "AADKERB". @@ -452,7 +446,7 @@ class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -653,7 +647,7 @@ class BlobInventoryPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -700,7 +694,7 @@ def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = No class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. - 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 filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyFilter @@ -903,7 +897,7 @@ def __init__( class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled when set to true. Required. :vartype enabled: bool @@ -964,7 +958,7 @@ class BlobInventoryPolicySchema(_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 enabled: Policy is enabled if set to true. Required. :vartype enabled: bool @@ -1019,7 +1013,7 @@ def __init__( class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. - 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 time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime @@ -1054,7 +1048,7 @@ def __init__( class BlobRestoreRange(_serialization.Model): """Blob range. - 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 start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str @@ -1154,7 +1148,7 @@ class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -1404,7 +1398,7 @@ def __init__( class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. - 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 allowed_origins: Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow all domains. Required. @@ -1499,7 +1493,7 @@ def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **k class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. - 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 name: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Required. @@ -1535,7 +1529,7 @@ def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **k class DateAfterCreation(_serialization.Model): """Object to define snapshot and version action conditions. - 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 days_after_creation_greater_than: Value indicating the age in days after creation. Required. @@ -1656,7 +1650,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. Ex - - /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 @@ -1665,22 +1659,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class DeletedAccount(ProxyResource): """Deleted storage account. @@ -1688,7 +1666,7 @@ class DeletedAccount(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. Ex - - /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 @@ -1772,7 +1750,7 @@ def __init__(self, **kwargs: Any) -> None: class DeletedShare(_serialization.Model): """The deleted share to be restored. - 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 deleted_share_name: Required. Identify the name of the deleted share that will be restored. Required. @@ -1984,7 +1962,7 @@ class EncryptionScope(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2503,7 +2481,7 @@ class FileServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2575,7 +2553,7 @@ class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2733,7 +2711,7 @@ class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-a Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -2983,7 +2961,7 @@ class Identity(_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 principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -3043,7 +3021,7 @@ class ImmutabilityPolicy(AzureEntityResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -3297,7 +3275,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. - 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 ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. Required. @@ -3359,7 +3337,7 @@ def __init__( class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. - 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 key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int @@ -3449,7 +3427,7 @@ def __init__( class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. - 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 enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool @@ -3509,10 +3487,10 @@ def __init__( class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerRequestEnum :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3551,7 +3529,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerRequestEnum :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3606,10 +3584,10 @@ def __init__( class LeaseShareRequest(_serialization.Model): """Lease Share request schema. - 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 action: Specifies the lease action. Can be one of the available actions. Required. Known - values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2023_01_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3648,7 +3626,7 @@ def __init__( ) -> None: """ :keyword action: Specifies the lease action. Can be one of the available actions. Required. - Known values are: "Acquire", "Renew", "Change", "Release", "Break", and "Break". + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2023_01_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3705,7 +3683,7 @@ class LegalHold(_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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing @@ -3852,7 +3830,7 @@ class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instan Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4056,7 +4034,7 @@ class ListQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4220,7 +4198,7 @@ class LocalUser(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4389,7 +4367,7 @@ class ManagementPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -4537,7 +4515,7 @@ class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. - 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 actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyAction @@ -4576,7 +4554,7 @@ class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. - 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 prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] @@ -4625,7 +4603,7 @@ def __init__( class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. - 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 enabled: Rule is enabled if set to true. :vartype enabled: bool @@ -4682,7 +4660,7 @@ class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - 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 rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. @@ -4923,7 +4901,7 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: class NetworkRuleSet(_serialization.Model): """Network rule set. - 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 bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), @@ -5016,7 +4994,7 @@ class ObjectReplicationPolicy(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5119,7 +5097,7 @@ def __init__( class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. - 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 rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. @@ -5287,7 +5265,7 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg class PermissionScope(_serialization.Model): """PermissionScope. - 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 permissions: The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create (c). Required. @@ -5357,7 +5335,7 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5442,7 +5420,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. Ex - - /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 @@ -5611,7 +5589,7 @@ class QueueServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -5679,7 +5657,7 @@ class RestorePolicyProperties(_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 enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool @@ -5812,7 +5790,7 @@ def __init__( class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. - 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 sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str @@ -5851,7 +5829,7 @@ def __init__( class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. - 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 canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str @@ -6074,7 +6052,7 @@ class Sku(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -6144,7 +6122,7 @@ class SkuInformation(_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 name: The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", @@ -6311,10 +6289,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. Ex - - /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 @@ -6359,10 +6337,10 @@ class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attr 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. Ex - - /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 @@ -6755,12 +6733,12 @@ def __init__( # pylint: disable=too-many-locals self.account_migration_in_progress = None -class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long """The parameters used to check the availability of the storage account name. 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 name: The storage account name. Required. :vartype name: str @@ -6793,7 +6771,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. - 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 sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2023_01_01.models.Sku @@ -7293,7 +7271,7 @@ class StorageAccountMigration(_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 id: Migration Resource Id. :vartype id: str @@ -7363,7 +7341,7 @@ def __init__( class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. - 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 key_name: The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. Required. @@ -7717,7 +7695,7 @@ class StorageQueue(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7850,7 +7828,7 @@ class Table(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7894,7 +7872,7 @@ def __init__( class TableAccessPolicy(_serialization.Model): """Table Access Policy Properties Object. - 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 start_time: Start time of the access policy. :vartype start_time: ~datetime.datetime @@ -7944,7 +7922,7 @@ class TableServiceProperties(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /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 @@ -7984,7 +7962,7 @@ def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) class TableSignedIdentifier(_serialization.Model): """Object to set Table Access Policy. - 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: unique-64-character-value of the stored access policy. Required. :vartype id: str @@ -8022,7 +8000,7 @@ def __init__( class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. - 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 name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str @@ -8312,10 +8290,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. Default value is "Allow". @@ -8345,7 +8323,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. Default value is "Allow". diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_storage_management_client_enums.py index 261ed4a5072e..f6a4eb0a48b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/models/_storage_management_client_enums.py @@ -294,7 +294,6 @@ class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" @@ -314,7 +313,6 @@ class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK = "Break" BREAK_ENUM = "Break" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_containers_operations.py index 1a8d4ff57669..a71a4a713f0a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_containers_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -314,7 +314,7 @@ def build_clear_legal_hold_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_immutability_policy_request( +def build_create_or_update_immutability_policy_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, container_name: str, @@ -667,7 +667,6 @@ def list( :param include: Optional, used to include the properties for soft deleted blob containers. "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2023_01_01.models.ListContainersInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.ListContainerItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -678,7 +677,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,7 +688,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -697,12 +696,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -713,14 +711,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListContainerItems", pipeline_response) @@ -730,11 +728,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 @@ -746,10 +744,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - } - @overload def create( self, @@ -782,7 +776,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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -794,7 +787,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -816,11 +809,10 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -832,7 +824,7 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -852,17 +844,13 @@ def create( by a letter or number. Required. :type container_name: str :param blob_container: Properties of the blob container to create. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -885,7 +873,7 @@ def create( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -894,16 +882,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -923,10 +910,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } - @overload def update( self, @@ -958,7 +941,6 @@ def 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 :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -970,7 +952,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: IO, + blob_container: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -991,11 +973,10 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Required. - :type blob_container: IO + :type blob_container: 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: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: @@ -1007,7 +988,7 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: Union[_models.BlobContainer, IO], + blob_container: Union[_models.BlobContainer, IO[bytes]], **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the @@ -1026,17 +1007,13 @@ def update( by a letter or number. Required. :type container_name: str :param blob_container: Properties to update for the blob container. Is either a BlobContainer - type or a IO type. Required. - :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer 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 + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer or IO[bytes] :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1059,7 +1036,7 @@ def update( else: _json = self._serialize.body(blob_container, "BlobContainer") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1068,16 +1045,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1089,13 +1065,9 @@ def update( deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -1115,12 +1087,11 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobContainer :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1134,22 +1105,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1161,13 +1131,9 @@ def get( deserialized = self._deserialize("BlobContainer", pipeline_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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1187,12 +1153,11 @@ def delete( # pylint: disable=inconsistent-return-statements letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1206,22 +1171,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1231,11 +1195,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def set_legal_hold( @@ -1269,7 +1229,6 @@ def set_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1281,7 +1240,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1303,11 +1262,10 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1319,7 +1277,7 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1339,17 +1297,13 @@ def set_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1372,7 +1326,7 @@ def set_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_set_legal_hold_request( + _request = build_set_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1381,16 +1335,15 @@ def set_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1402,13 +1355,9 @@ def set_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - set_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - } + return deserialized # type: ignore @overload def clear_legal_hold( @@ -1441,7 +1390,6 @@ def clear_legal_hold( :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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1453,7 +1401,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: IO, + legal_hold: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1474,11 +1422,10 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Required. - :type legal_hold: IO + :type legal_hold: 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: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: @@ -1490,7 +1437,7 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: Union[_models.LegalHold, IO], + legal_hold: Union[_models.LegalHold, IO[bytes]], **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent @@ -1509,17 +1456,13 @@ def clear_legal_hold( by a letter or number. Required. :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a - LegalHold type or a IO type. Required. - :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold 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 + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_01_01.models.LegalHold or IO[bytes] :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LegalHold :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1542,7 +1485,7 @@ def clear_legal_hold( else: _json = self._serialize.body(legal_hold, "LegalHold") - request = build_clear_legal_hold_request( + _request = build_clear_legal_hold_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1551,16 +1494,15 @@ def clear_legal_hold( content_type=content_type, json=_json, content=_content, - template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1572,13 +1514,9 @@ def clear_legal_hold( deserialized = self._deserialize("LegalHold", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - clear_legal_hold.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - } + return deserialized # type: ignore @overload def create_or_update_immutability_policy( @@ -1617,11 +1555,6 @@ def create_or_update_immutability_policy( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1634,7 +1567,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1660,15 +1593,10 @@ def create_or_update_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. - :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 immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -1681,7 +1609,7 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but @@ -1704,21 +1632,13 @@ def create_or_update_immutability_policy( omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy or IO - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1745,7 +1665,7 @@ def create_or_update_immutability_policy( else: _json = None - request = build_create_or_update_immutability_policy_request( + _request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1756,16 +1676,15 @@ def create_or_update_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1780,13 +1699,9 @@ def create_or_update_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create_or_update_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get_immutability_policy( @@ -1816,16 +1731,11 @@ def get_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1840,7 +1750,7 @@ def get_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_get_immutability_policy_request( + _request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1848,16 +1758,15 @@ def get_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1872,13 +1781,9 @@ def get_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete_immutability_policy( @@ -1905,16 +1810,11 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1929,7 +1829,7 @@ def delete_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_delete_immutability_policy_request( + _request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -1937,16 +1837,15 @@ def delete_immutability_policy( if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1961,13 +1860,9 @@ def delete_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - delete_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - } + return deserialized # type: ignore @distributed_trace def lock_immutability_policy( @@ -1992,12 +1887,11 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Required. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2011,23 +1905,22 @@ def lock_immutability_policy( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) - request = build_lock_immutability_policy_request( + _request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2042,13 +1935,9 @@ def lock_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - lock_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - } + return deserialized # type: ignore @overload def extend_immutability_policy( @@ -2088,7 +1977,6 @@ def extend_immutability_policy( :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: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2101,7 +1989,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2128,11 +2016,10 @@ def extend_immutability_policy( :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. - :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 :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -2145,7 +2032,7 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -2169,17 +2056,13 @@ def extend_immutability_policy( omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. Is either a ImmutabilityPolicy type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy 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 + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy or IO[bytes] :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ImmutabilityPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2205,7 +2088,7 @@ def extend_immutability_policy( else: _json = None - request = build_extend_immutability_policy_request( + _request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2215,16 +2098,15 @@ def extend_immutability_policy( content_type=content_type, json=_json, content=_content, - template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2239,13 +2121,9 @@ def extend_immutability_policy( deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - extend_immutability_policy.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - } + return deserialized # type: ignore @overload def lease( @@ -2278,7 +2156,6 @@ def lease( :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: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2290,7 +2167,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2311,11 +2188,10 @@ def lease( by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. - :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 :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -2327,7 +2203,7 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete @@ -2345,18 +2221,14 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_name: str - :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerRequest 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 + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerRequest or IO[bytes] :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseContainerResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2382,7 +2254,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, @@ -2391,16 +2263,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2412,18 +2283,14 @@ def lease( deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - } + return deserialized # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2437,22 +2304,21 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_object_level_worm_request( + _request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2462,11 +2328,7 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _object_level_worm_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_object_level_worm( @@ -2489,14 +2351,6 @@ def begin_object_level_worm( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type container_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: @@ -2524,7 +2378,7 @@ def begin_object_level_worm( 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( @@ -2535,14 +2389,10 @@ 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_object_level_worm.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_inventory_policies_operations.py index 7a13a05c5803..519d1b591c98 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_inventory_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -234,12 +239,11 @@ def get( should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,22 +257,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -280,13 +283,9 @@ def get( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -317,7 +316,6 @@ def 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 :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -329,7 +327,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -348,11 +346,10 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. 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: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +361,7 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], - properties: Union[_models.BlobInventoryPolicy, IO], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. @@ -381,17 +378,13 @@ def create_or_update( :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName :param properties: The blob inventory policy set to a storage account. Is either a - BlobInventoryPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy 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 + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy or IO[bytes] :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -414,7 +407,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "BlobInventoryPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, @@ -423,16 +416,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -444,13 +436,9 @@ def create_or_update( deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -473,12 +461,11 @@ def delete( # pylint: disable=inconsistent-return-statements should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -492,22 +479,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, blob_inventory_policy_name=blob_inventory_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -517,11 +503,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -536,7 +518,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.BlobInventoryPolicy] @@ -548,7 +529,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,17 +540,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -580,14 +560,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) @@ -597,11 +577,11 @@ def extract_data(pipeline_response): 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 @@ -613,7 +593,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_services_operations.py index 8eccbdaefc37..22790f8c0773 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_blob_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -31,10 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -185,7 +185,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BlobServiceProperties or the result of cls(response) :rtype: @@ -198,7 +197,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,17 +208,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -230,14 +228,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BlobServiceItems", pipeline_response) @@ -247,11 +245,11 @@ def extract_data(pipeline_response): 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 @@ -263,10 +261,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - } - @overload def set_service_properties( self, @@ -293,11 +287,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +297,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -325,15 +314,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. 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 blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -344,7 +328,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobServiceProperties, IO], + parameters: Union[_models.BlobServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage @@ -359,21 +343,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a - BlobServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties or IO - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :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 + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties or IO[bytes] :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,7 +373,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "BlobServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -406,16 +382,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -427,13 +402,9 @@ def set_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -449,16 +420,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.BlobServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -473,22 +439,21 @@ def get_service_properties( blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -500,10 +465,6 @@ def get_service_properties( deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_deleted_accounts_operations.py index e273e9c45cd6..b1309c8fb713 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_deleted_accounts_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -115,7 +120,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.DeletedAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -126,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,15 +141,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -156,14 +159,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) @@ -173,11 +176,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 @@ -190,8 +193,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} - @distributed_trace def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. @@ -200,12 +201,11 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model :type deleted_account_name: str :param location: The location of the deleted storage account. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.DeletedAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,21 +219,20 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( deleted_account_name=deleted_account_name, location=location, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +245,6 @@ def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _model deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_encryption_scopes_operations.py index 19c7720a4839..9aab933c2612 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_encryption_scopes_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -258,7 +263,6 @@ def put( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +274,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -293,11 +297,10 @@ def put( :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +312,7 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -329,17 +332,13 @@ def put( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. Is - either a EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope 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 + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -362,7 +361,7 @@ def put( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -371,16 +370,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,10 +399,6 @@ def put( return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } - @overload def patch( self, @@ -436,7 +430,6 @@ def patch( :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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -448,7 +441,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: IO, + encryption_scope: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -469,11 +462,10 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Required. - :type encryption_scope: IO + :type encryption_scope: 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: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: @@ -485,7 +477,7 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: Union[_models.EncryptionScope, IO], + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the @@ -504,17 +496,13 @@ def patch( followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the update. Is either a - EncryptionScope type or a IO type. Required. - :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope 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 + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope or IO[bytes] :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,7 +525,7 @@ def patch( else: _json = self._serialize.body(encryption_scope, "EncryptionScope") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_name, @@ -546,16 +534,15 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,13 +555,9 @@ def patch( deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -594,12 +577,11 @@ def get( lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type encryption_scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.EncryptionScope :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -613,22 +595,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, encryption_scope_name=encryption_scope_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -641,13 +622,9 @@ def get( deserialized = self._deserialize("EncryptionScope", pipeline_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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -677,7 +654,6 @@ def list( :param include: Optional, when specified, will list encryption scopes with the specific state. Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. :type include: str or ~azure.mgmt.storage.v2023_01_01.models.ListEncryptionScopesInclude - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.EncryptionScope] :raises ~azure.core.exceptions.HttpResponseError: @@ -688,7 +664,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -699,7 +675,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -707,12 +683,11 @@ def prepare_request(next_link=None): filter=filter, include=include, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -723,14 +698,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) @@ -740,11 +715,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 @@ -755,7 +730,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_services_operations.py index 7088388f9d59..3dd19e0f6ba9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -181,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceItems :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -260,11 +254,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -275,7 +264,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,15 +281,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. 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 file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +295,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.FileServiceProperties, IO], + parameters: Union[_models.FileServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource @@ -325,22 +309,14 @@ def set_service_properties( lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO type. - Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties or IO - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :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 + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties or IO[bytes] :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +340,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "FileServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -373,16 +349,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -394,13 +369,9 @@ def set_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -416,16 +387,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,22 +406,21 @@ def get_service_properties( file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -467,10 +432,6 @@ def get_service_properties( deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_shares_operations.py index a213bd343501..193b91228cd6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_file_shares_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -400,7 +405,6 @@ def list( are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.FileShareItem] :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +415,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -422,7 +426,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -430,12 +434,11 @@ def prepare_request(next_link=None): filter=filter, expand=expand, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -446,14 +449,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FileShareItems", pipeline_response) @@ -463,11 +466,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 @@ -479,10 +482,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - } - @overload def create( self, @@ -519,7 +518,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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -531,7 +529,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], expand: Optional[str] = None, *, content_type: str = "application/json", @@ -554,14 +552,13 @@ def create( or number. Required. :type share_name: str :param file_share: Properties of the file share to create. Required. - :type file_share: IO + :type file_share: IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -573,7 +570,7 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], expand: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: @@ -593,21 +590,17 @@ def create( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare or IO + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare or IO[bytes] :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -630,7 +623,7 @@ def create( else: _json = self._serialize.body(file_share, "FileShare") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -640,16 +633,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -669,10 +661,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } - @overload def update( self, @@ -704,7 +692,6 @@ def 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 :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -716,7 +703,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: IO, + file_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -737,11 +724,10 @@ def update( or number. Required. :type share_name: str :param file_share: Properties to update for the file share. Required. - :type file_share: IO + :type file_share: 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: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: @@ -753,7 +739,7 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: Union[_models.FileShare, IO], + file_share: Union[_models.FileShare, IO[bytes]], **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request @@ -771,18 +757,14 @@ def update( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. Is either a FileShare type or a IO - type. Required. - :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare 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 + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_01_01.models.FileShare or IO[bytes] :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -805,7 +787,7 @@ def update( else: _json = self._serialize.body(file_share, "FileShare") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -814,16 +796,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -835,13 +816,9 @@ def update( deserialized = self._deserialize("FileShare", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -873,12 +850,11 @@ def get( :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.FileShare :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -892,7 +868,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -900,16 +876,15 @@ def get( expand=expand, x_ms_snapshot=x_ms_snapshot, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -921,13 +896,9 @@ def get( deserialized = self._deserialize("FileShare", pipeline_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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -963,12 +934,11 @@ def delete( # pylint: disable=inconsistent-return-statements file share contains any snapshots (leased or unleased), the deletion fails. Default value is None. :type include: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,7 +952,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -990,16 +960,15 @@ def delete( # pylint: disable=inconsistent-return-statements x_ms_snapshot=x_ms_snapshot, include=include, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1009,11 +978,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def restore( # pylint: disable=inconsistent-return-statements @@ -1045,7 +1010,6 @@ def restore( # pylint: disable=inconsistent-return-statements :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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1057,7 +1021,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: IO, + deleted_share: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1077,11 +1041,10 @@ def restore( # pylint: disable=inconsistent-return-statements or number. Required. :type share_name: str :param deleted_share: Required. - :type deleted_share: IO + :type deleted_share: 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -1093,7 +1056,7 @@ def restore( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, share_name: str, - deleted_share: Union[_models.DeletedShare, IO], + deleted_share: Union[_models.DeletedShare, IO[bytes]], **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -1110,17 +1073,13 @@ def restore( # pylint: disable=inconsistent-return-statements dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. Required. :type share_name: str - :param deleted_share: Is either a DeletedShare type or a IO type. Required. - :type deleted_share: ~azure.mgmt.storage.v2023_01_01.models.DeletedShare 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 + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2023_01_01.models.DeletedShare or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1143,7 +1102,7 @@ def restore( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(deleted_share, "DeletedShare") - request = build_restore_request( + _request = build_restore_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1152,16 +1111,15 @@ def restore( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1171,11 +1129,7 @@ def restore( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def lease( @@ -1212,7 +1166,6 @@ def lease( :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: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1225,7 +1178,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1249,11 +1202,10 @@ def lease( None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. - :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 :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1266,7 +1218,7 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The @@ -1287,18 +1239,14 @@ def lease( :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareRequest 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 + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareRequest or IO[bytes] :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LeaseShareResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1324,7 +1272,7 @@ def lease( else: _json = None - request = build_lease_request( + _request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, @@ -1334,16 +1282,15 @@ def lease( content_type=content_type, json=_json, content=_content, - template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1358,10 +1305,6 @@ def lease( deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - lease.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_local_users_operations.py index 5c3b89eaecc0..3f554e0ed8c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_local_users_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -284,7 +289,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.LocalUser] :raises ~azure.core.exceptions.HttpResponseError: @@ -295,7 +299,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,17 +310,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -327,14 +330,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LocalUsers", pipeline_response) @@ -344,11 +347,11 @@ def extract_data(pipeline_response): 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 @@ -361,10 +364,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. @@ -379,12 +378,11 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -398,22 +396,21 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, username=username, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -426,13 +423,9 @@ def get(self, resource_group_name: str, account_name: str, username: str, **kwar deserialized = self._deserialize("LocalUser", pipeline_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.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -462,7 +455,6 @@ def 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 :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -474,7 +466,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -492,11 +484,10 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. 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: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: @@ -508,7 +499,7 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: Union[_models.LocalUser, IO], + properties: Union[_models.LocalUser, IO[bytes]], **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. @@ -524,17 +515,13 @@ def create_or_update( numbers only. It must be unique only within the storage account. Required. :type username: str :param properties: The local user associated with a storage account. Is either a LocalUser type - or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.LocalUser 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 + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.LocalUser or IO[bytes] :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUser :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -557,7 +544,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "LocalUser") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, username=username, @@ -566,16 +553,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -588,13 +574,9 @@ def create_or_update( deserialized = self._deserialize("LocalUser", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -612,12 +594,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -631,22 +612,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -657,11 +637,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_keys( @@ -679,12 +655,11 @@ def list_keys( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUserKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -698,22 +673,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -726,13 +700,9 @@ def list_keys( deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys" - } + return deserialized # type: ignore @distributed_trace def regenerate_password( @@ -750,12 +720,11 @@ def regenerate_password( :param username: The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account. Required. :type username: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.LocalUserRegeneratePasswordResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -769,22 +738,21 @@ def regenerate_password( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) - request = build_regenerate_password_request( + _request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, username=username, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -797,10 +765,6 @@ def regenerate_password( deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_management_policies_operations.py index aadba418f681..5eccc48f072f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_management_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -28,6 +29,10 @@ 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]] @@ -193,12 +198,11 @@ def get( always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,22 +216,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,13 +242,9 @@ def get( deserialized = self._deserialize("ManagementPolicy", pipeline_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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -276,7 +275,6 @@ def 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 :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -288,7 +286,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -307,11 +305,10 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. 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: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -323,7 +320,7 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, _models.ManagementPolicyName], - properties: Union[_models.ManagementPolicy, IO], + properties: Union[_models.ManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. @@ -340,17 +337,13 @@ def create_or_update( :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy - type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy 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 + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy or IO[bytes] :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,7 +366,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ManagementPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, @@ -382,16 +375,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,13 +395,9 @@ def create_or_update( deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -432,12 +420,11 @@ def delete( # pylint: disable=inconsistent-return-statements always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2023_01_01.models.ManagementPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -451,22 +438,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, management_policy_name=management_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,8 +462,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_object_replication_policies_operations.py index 739094e875c4..6c8c4f746509 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_object_replication_policies_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -220,7 +225,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: @@ -233,7 +237,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,17 +248,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -265,14 +268,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) @@ -282,11 +285,11 @@ def extract_data(pipeline_response): 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 @@ -299,10 +302,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any @@ -321,12 +320,11 @@ def get( value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -340,22 +338,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,13 +365,9 @@ def get( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -407,7 +400,6 @@ def 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 :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -419,7 +411,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -440,11 +432,10 @@ def create_or_update( :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID will be created if absent. 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: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -456,7 +447,7 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: Union[_models.ObjectReplicationPolicy, IO], + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. @@ -474,17 +465,14 @@ def create_or_update( destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. Is either a ObjectReplicationPolicy type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy 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 + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy or IO[bytes] :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ObjectReplicationPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,7 +495,7 @@ def create_or_update( else: _json = self._serialize.body(properties, "ObjectReplicationPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, @@ -516,16 +504,15 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,13 +525,9 @@ def create_or_update( deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -564,12 +547,11 @@ def delete( # pylint: disable=inconsistent-return-statements value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,22 +565,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, object_replication_policy_id=object_replication_policy_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,8 +590,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_operations.py index bb5d383180f6..56dbe6bf4e1f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -79,7 +84,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,14 +105,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,14 +122,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -136,11 +139,11 @@ def extract_data(pipeline_response): 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 @@ -151,5 +154,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Storage/operations"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_private_endpoint_connections_operations.py index 7477782ed3ab..ca36fdcccb86 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/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. @@ -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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -232,7 +237,6 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -245,7 +249,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,17 +260,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -277,14 +280,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -294,11 +297,11 @@ def extract_data(pipeline_response): 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 @@ -310,10 +313,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -330,12 +329,11 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,22 +347,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -377,13 +374,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def put( @@ -413,7 +406,6 @@ def put( :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.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +417,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -443,11 +435,10 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. 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.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -459,7 +450,7 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. @@ -475,17 +466,13 @@ def put( with the Azure resource. Required. :type private_endpoint_connection_name: str :param properties: The private endpoint connection properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.storage.v2023_01_01.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.storage.v2023_01_01.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,7 +495,7 @@ def put( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -517,16 +504,15 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -539,13 +525,9 @@ def put( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -563,12 +545,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param private_endpoint_connection_name: The name of the private endpoint connection associated with the Azure resource. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,22 +563,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,8 +588,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_private_link_resources_operations.py index 359935408a5a..e0aba5583ba6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_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,8 @@ # 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, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ 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]] @@ -102,12 +107,11 @@ def list_by_storage_account( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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.storage.v2023_01_01.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,21 +125,20 @@ def list_by_storage_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_storage_account_request( + _request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,10 +150,6 @@ def list_by_storage_account( deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_storage_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_operations.py index 011686a310cb..2720242f48e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -310,7 +315,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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -322,7 +326,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -342,11 +346,10 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -358,7 +361,7 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -376,17 +379,13 @@ def create( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,7 +408,7 @@ def create( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -418,16 +417,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -439,13 +437,9 @@ def create( deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @overload def update( @@ -477,7 +471,6 @@ def 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 :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -489,7 +482,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: IO, + queue: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -509,11 +502,10 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Required. - :type queue: IO + :type queue: 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: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: @@ -525,7 +517,7 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: Union[_models.StorageQueue, IO], + queue: Union[_models.StorageQueue, IO[bytes]], **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. @@ -543,17 +535,13 @@ def update( dash(-) characters. Required. :type queue_name: str :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type - or a IO type. Required. - :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue 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 + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue or IO[bytes] :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,7 +564,7 @@ def update( else: _json = self._serialize.body(queue, "StorageQueue") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, @@ -585,16 +573,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -606,13 +593,9 @@ def update( deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: @@ -630,12 +613,11 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageQueue :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -649,22 +631,21 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -676,13 +657,9 @@ def get(self, resource_group_name: str, account_name: str, queue_name: str, **kw deserialized = self._deserialize("StorageQueue", pipeline_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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -702,12 +679,11 @@ def delete( # pylint: disable=inconsistent-return-statements it should begin and end with an alphanumeric character and it cannot have two consecutive dash(-) characters. Required. :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -721,22 +697,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -746,11 +721,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -776,7 +747,6 @@ def list( :param filter: Optional, When specified, only the queues with a name starting with the given filter will be listed. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.ListQueue] :raises ~azure.core.exceptions.HttpResponseError: @@ -787,7 +757,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -798,19 +768,18 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxpagesize=maxpagesize, filter=filter, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -821,14 +790,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListQueueResource", pipeline_response) @@ -838,11 +807,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 @@ -853,7 +822,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_services_operations.py index 73c07e073cfb..323c25562021 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_queue_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -181,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListQueueServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -260,11 +254,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -275,7 +264,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,15 +281,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +295,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.QueueServiceProperties, IO], + parameters: Union[_models.QueueServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage @@ -326,21 +310,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - QueueServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties or IO - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :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 + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties or IO[bytes] :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +340,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "QueueServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -373,16 +349,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -394,13 +369,9 @@ def set_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -416,16 +387,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.QueueServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,22 +406,21 @@ def get_service_properties( queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -467,10 +432,6 @@ def get_service_properties( deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_skus_operations.py index 21b5c054b07d..1c096f272047 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_skus_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -84,7 +89,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,7 +99,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,15 +110,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,14 +128,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageSkuListResult", pipeline_response) @@ -142,11 +145,11 @@ def extract_data(pipeline_response): 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 @@ -157,5 +160,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_storage_accounts_operations.py index 5616c70148fe..3a5b128f947b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_storage_accounts_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -33,10 +33,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -466,7 +466,7 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request( +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -502,7 +502,7 @@ def build_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request( +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -537,7 +537,7 @@ def build_abort_hierarchical_namespace_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_customer_initiated_migration_request( +def build_customer_initiated_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -575,7 +575,7 @@ def build_customer_initiated_migration_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_customer_initiated_migration_request( +def build_get_customer_initiated_migration_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, migration_name: Union[str, _models.MigrationName], @@ -653,7 +653,7 @@ def build_restore_blob_ranges_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_revoke_user_delegation_keys_request( +def build_revoke_user_delegation_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -718,7 +718,6 @@ def check_name_availability( :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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -726,18 +725,17 @@ def check_name_availability( @overload def check_name_availability( - self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. - :type account_name: IO + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -745,25 +743,22 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a IO - type. Required. + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. :type account_name: - ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCheckNameAvailabilityParameters 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 + ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -786,22 +781,21 @@ def check_name_availability( else: _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -813,22 +807,18 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> Optional[_models.StorageAccount]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -851,7 +841,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -859,16 +849,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -882,13 +871,9 @@ def _create_initial( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -917,14 +902,6 @@ def begin_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 - :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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] @@ -936,7 +913,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -954,18 +931,10 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. 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 StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] @@ -977,7 +946,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountCreateParameters, IO], + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -993,19 +962,9 @@ def begin_create( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the created account. Is either a - StorageAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCreateParameters 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. + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountCreateParameters or + IO[bytes] :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] @@ -1037,7 +996,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1047,17 +1006,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageAccount].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1072,12 +1029,11 @@ def delete( # pylint: disable=inconsistent-return-statements Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1091,21 +1047,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1115,11 +1070,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_properties( @@ -1145,12 +1096,11 @@ def get_properties( and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default value is None. :type expand: str or ~azure.mgmt.storage.v2023_01_01.models.StorageAccountExpand - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1164,22 +1114,21 @@ def get_properties( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) - request = build_get_properties_request( + _request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1191,13 +1140,9 @@ def get_properties( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @overload def update( @@ -1230,7 +1175,6 @@ def 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1241,7 +1185,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1263,11 +1207,10 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. 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 :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -1278,7 +1221,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountUpdateParameters, IO], + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1298,17 +1241,14 @@ def update( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for the updated account. Is either a - StorageAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountUpdateParameters 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 + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountUpdateParameters or + IO[bytes] :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1331,7 +1271,7 @@ def update( else: _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1339,16 +1279,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1360,20 +1299,15 @@ def update( deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1384,7 +1318,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1395,15 +1329,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1414,14 +1347,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1431,11 +1364,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 @@ -1447,8 +1380,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys @@ -1457,7 +1388,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1468,7 +1398,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1479,16 +1409,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite 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, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1499,14 +1428,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageAccountListResult", pipeline_response) @@ -1516,11 +1445,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 @@ -1532,10 +1461,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - } - @distributed_trace def list_keys( self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any @@ -1553,12 +1478,11 @@ def list_keys( :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are "kerb" and None. Default value is "kerb". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1572,22 +1496,21 @@ def list_keys( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1599,13 +1522,9 @@ def list_keys( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @overload def regenerate_key( @@ -1633,7 +1552,6 @@ def regenerate_key( :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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1644,7 +1562,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: IO, + regenerate_key: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1660,11 +1578,10 @@ def regenerate_key( :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. Required. - :type regenerate_key: IO + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1675,7 +1592,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. @@ -1688,18 +1605,15 @@ def regenerate_key( lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO type. Required. + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. :type regenerate_key: - ~azure.mgmt.storage.v2023_01_01.models.StorageAccountRegenerateKeyParameters 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 + ~azure.mgmt.storage.v2023_01_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountListKeysResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1722,7 +1636,7 @@ def regenerate_key( else: _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1730,16 +1644,15 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1751,13 +1664,9 @@ def regenerate_key( deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - } + return deserialized # type: ignore @overload def list_account_sas( @@ -1784,7 +1693,6 @@ def list_account_sas( :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: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1795,7 +1703,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1811,11 +1719,10 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. 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 :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1826,7 +1733,7 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.AccountSasParameters, IO], + parameters: Union[_models.AccountSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. @@ -1839,17 +1746,13 @@ def list_account_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. - Is either a AccountSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.AccountSasParameters 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 + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.AccountSasParameters or IO[bytes] :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListAccountSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1872,7 +1775,7 @@ def list_account_sas( else: _json = self._serialize.body(parameters, "AccountSasParameters") - request = build_list_account_sas_request( + _request = build_list_account_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1880,16 +1783,15 @@ def list_account_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1901,13 +1803,9 @@ def list_account_sas( deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_account_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - } + return deserialized # type: ignore @overload def list_service_sas( @@ -1933,7 +1831,6 @@ def list_service_sas( :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: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1944,7 +1841,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1959,11 +1856,10 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. 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 :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -1974,7 +1870,7 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: Union[_models.ServiceSasParameters, IO], + parameters: Union[_models.ServiceSasParameters, IO[bytes]], **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. @@ -1987,17 +1883,13 @@ def list_service_sas( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. Is either a - ServiceSasParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ServiceSasParameters 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 + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.ServiceSasParameters or IO[bytes] :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListServiceSasResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2020,7 +1912,7 @@ def list_service_sas( else: _json = self._serialize.body(parameters, "ServiceSasParameters") - request = build_list_service_sas_request( + _request = build_list_service_sas_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2028,16 +1920,15 @@ def list_service_sas( content_type=content_type, json=_json, content=_content, - template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2049,18 +1940,14 @@ def list_service_sas( deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_service_sas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - } + return deserialized # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2074,22 +1961,21 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_failover_request( + _request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, failover_type=failover_type, api_version=api_version, - template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2099,11 +1985,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _failover_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_failover( @@ -2131,14 +2013,6 @@ def begin_failover( :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover is requested. Known values are "Planned" and None. Default value is "Planned". :type failover_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2166,7 +2040,7 @@ def begin_failover( 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( @@ -2177,22 +2051,18 @@ 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_failover.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2206,22 +2076,21 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_hierarchical_namespace_migration_request( + _request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, request_type=request_type, api_version=api_version, - template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2232,11 +2101,7 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_hierarchical_namespace_migration( @@ -2256,14 +2121,6 @@ def begin_hierarchical_namespace_migration( 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the hydration request will migrate the account. Required. :type request_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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2291,7 +2148,7 @@ def begin_hierarchical_namespace_migration( 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( @@ -2302,22 +2159,18 @@ 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 + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration" - } - - def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2331,21 +2184,20 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_abort_hierarchical_namespace_migration_request( + _request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2356,14 +2208,10 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _abort_hierarchical_namespace_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. @@ -2375,14 +2223,6 @@ def begin_abort_hierarchical_namespace_migration( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_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: @@ -2409,7 +2249,7 @@ def begin_abort_hierarchical_namespace_migration( 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( @@ -2420,26 +2260,22 @@ 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_abort_hierarchical_namespace_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _customer_initiated_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountMigration, IO], + parameters: Union[_models.StorageAccountMigration, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2462,7 +2298,7 @@ def _customer_initiated_migration_initial( # pylint: disable=inconsistent-retur else: _json = self._serialize.body(parameters, "StorageAccountMigration") - request = build_customer_initiated_migration_request( + _request = build_customer_initiated_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2470,16 +2306,15 @@ def _customer_initiated_migration_initial( # pylint: disable=inconsistent-retur content_type=content_type, json=_json, content=_content, - template_url=self._customer_initiated_migration_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2494,11 +2329,7 @@ def _customer_initiated_migration_initial( # pylint: disable=inconsistent-retur response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _customer_initiated_migration_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/startAccountMigration" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload def begin_customer_initiated_migration( @@ -2529,14 +2360,6 @@ def begin_customer_initiated_migration( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2547,7 +2370,7 @@ def begin_customer_initiated_migration( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2567,18 +2390,10 @@ def begin_customer_initiated_migration( :type account_name: str :param parameters: The request parameters required to perform storage account migration. 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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2589,7 +2404,7 @@ def begin_customer_initiated_migration( self, resource_group_name: str, account_name: str, - parameters: Union[_models.StorageAccountMigration, IO], + parameters: Union[_models.StorageAccountMigration, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Account Migration request can be triggered for a storage account to change its redundancy @@ -2606,19 +2421,8 @@ def begin_customer_initiated_migration( lower-case letters only. Required. :type account_name: str :param parameters: The request parameters required to perform storage account migration. Is - either a StorageAccountMigration type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountMigration 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. + either a StorageAccountMigration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountMigration or IO[bytes] :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: @@ -2648,7 +2452,7 @@ def begin_customer_initiated_migration( 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( @@ -2659,17 +2463,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_customer_initiated_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/startAccountMigration" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get_customer_initiated_migration( @@ -2691,12 +2491,11 @@ def get_customer_initiated_migration( :param migration_name: The name of the Storage Account Migration. It should always be 'default'. "default" Required. :type migration_name: str or ~azure.mgmt.storage.v2023_01_01.models.MigrationName - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountMigration or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.StorageAccountMigration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2710,22 +2509,21 @@ def get_customer_initiated_migration( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.StorageAccountMigration] = kwargs.pop("cls", None) - request = build_get_customer_initiated_migration_request( + _request = build_get_customer_initiated_migration_request( resource_group_name=resource_group_name, account_name=account_name, migration_name=migration_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_customer_initiated_migration.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2738,22 +2536,18 @@ def get_customer_initiated_migration( deserialized = self._deserialize("StorageAccountMigration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_customer_initiated_migration.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/accountMigrations/{migrationName}" - } + return deserialized # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> _models.BlobRestoreStatus: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2776,7 +2570,7 @@ def _restore_blob_ranges_initial( else: _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request( + _request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -2784,16 +2578,15 @@ def _restore_blob_ranges_initial( content_type=content_type, json=_json, content=_content, - template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2813,10 +2606,6 @@ def _restore_blob_ranges_initial( return deserialized # type: ignore - _restore_blob_ranges_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } - @overload def begin_restore_blob_ranges( self, @@ -2841,14 +2630,6 @@ def begin_restore_blob_ranges( :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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_01_01.models.BlobRestoreStatus] @@ -2860,7 +2641,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2875,18 +2656,10 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. 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 BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_01_01.models.BlobRestoreStatus] @@ -2898,7 +2671,7 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BlobRestoreParameters, IO], + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. @@ -2911,19 +2684,8 @@ def begin_restore_blob_ranges( lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide for restore blob ranges. Is either a - BlobRestoreParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobRestoreParameters 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. + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.BlobRestoreParameters or IO[bytes] :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_01_01.models.BlobRestoreStatus] @@ -2955,7 +2717,7 @@ def begin_restore_blob_ranges( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2967,17 +2729,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BlobRestoreStatus].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_restore_blob_ranges.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - } + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements @@ -2992,12 +2752,11 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3011,21 +2770,20 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revoke_user_delegation_keys_request( + _request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3035,8 +2793,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - revoke_user_delegation_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_operations.py index d8e361e0d25b..d369af3f9a90 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_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, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -30,6 +31,10 @@ 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]] @@ -277,7 +282,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: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -289,7 +293,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -308,11 +312,10 @@ def create( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +327,7 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -340,18 +343,14 @@ def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -377,7 +376,7 @@ def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -386,16 +385,15 @@ 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -407,13 +405,9 @@ def create( deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @overload def update( @@ -444,7 +438,6 @@ def 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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -456,7 +449,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -475,11 +468,10 @@ def update( with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. - :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 :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: @@ -491,7 +483,7 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional[Union[_models.Table, IO]] = None, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. @@ -507,18 +499,14 @@ def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :param parameters: The parameters to provide to create a table. Is either a Table type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table 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 + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.Table or IO[bytes] :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -544,7 +532,7 @@ def update( else: _json = None - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, @@ -553,16 +541,15 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -574,13 +561,9 @@ def update( deserialized = self._deserialize("Table", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: @@ -597,12 +580,11 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.Table :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,22 +598,21 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.Table] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -643,13 +624,9 @@ def get(self, resource_group_name: str, account_name: str, table_name: str, **kw deserialized = self._deserialize("Table", pipeline_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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -668,12 +645,11 @@ def delete( # pylint: disable=inconsistent-return-statements and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -687,22 +663,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -712,11 +687,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: @@ -729,7 +700,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Table or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.Table] :raises ~azure.core.exceptions.HttpResponseError: @@ -740,7 +710,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -751,17 +721,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -772,14 +741,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListTableResource", pipeline_response) @@ -789,11 +758,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 @@ -804,7 +773,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_services_operations.py index ae9b00921daa..add8f0feddf3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_table_services_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. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -181,12 +181,11 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.ListTableServices :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,21 +199,20 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,13 +224,9 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _m deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - } + return deserialized # type: ignore @overload def set_service_properties( @@ -260,11 +254,6 @@ def set_service_properties( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -275,7 +264,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,15 +281,10 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. 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 table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +295,7 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: Union[_models.TableServiceProperties, IO], + parameters: Union[_models.TableServiceProperties, IO[bytes]], **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage @@ -326,21 +310,13 @@ def set_service_properties( :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a - TableServiceProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties or IO - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :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 + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties or IO[bytes] :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +340,7 @@ def set_service_properties( else: _json = self._serialize.body(parameters, "TableServiceProperties") - request = build_set_service_properties_request( + _request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -373,16 +349,15 @@ def set_service_properties( content_type=content_type, json=_json, content=_content, - template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -394,13 +369,9 @@ def set_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - set_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore @distributed_trace def get_service_properties( @@ -416,16 +387,11 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2023_01_01.models.TableServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,22 +406,21 @@ def get_service_properties( table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) - request = build_get_service_properties_request( + _request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -467,10 +432,6 @@ def get_service_properties( deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_service_properties.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - } + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_usages_operations.py index 965013b45d99..10b5ea1d9165 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_01_01/operations/_usages_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,8 @@ # 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 ( @@ -29,6 +30,10 @@ 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]] @@ -90,7 +95,6 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_01_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +105,7 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +116,15 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Us def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + _request = build_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,14 +135,14 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("UsageListResult", pipeline_response) @@ -149,11 +152,11 @@ def extract_data(pipeline_response): 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 @@ -164,7 +167,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - } diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/__init__.py new file mode 100644 index 000000000000..a860a5c185c9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/__init__.py @@ -0,0 +1,26 @@ +# 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 ._storage_management_client import StorageManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StorageManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_configuration.py new file mode 100644 index 000000000000..ef14ed56fef4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-05-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + 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-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.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( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_metadata.json new file mode 100644 index 000000000000..fa4c951b32b2 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_metadata.json @@ -0,0 +1,133 @@ +{ + "chosen_version": "2023-05-01", + "total_api_version_list": ["2023-05-01"], + "client": { + "name": "StorageManagementClient", + "filename": "_storage_management_client", + "description": "The Azure Storage Management API.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_public_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "blob_services": "BlobServicesOperations", + "blob_containers": "BlobContainersOperations", + "file_services": "FileServicesOperations", + "file_shares": "FileSharesOperations", + "queue_services": "QueueServicesOperations", + "queue": "QueueOperations", + "operations": "Operations", + "skus": "SkusOperations", + "storage_accounts": "StorageAccountsOperations", + "deleted_accounts": "DeletedAccountsOperations", + "usages": "UsagesOperations", + "management_policies": "ManagementPoliciesOperations", + "blob_inventory_policies": "BlobInventoryPoliciesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "object_replication_policies": "ObjectReplicationPoliciesOperations", + "local_users": "LocalUsersOperations", + "encryption_scopes": "EncryptionScopesOperations", + "table_services": "TableServicesOperations", + "table": "TableOperations", + "network_security_perimeter_configurations": "NetworkSecurityPerimeterConfigurationsOperations", + "storage_task_assignments": "StorageTaskAssignmentsOperations", + "storage_task_assignments_instances_report": "StorageTaskAssignmentsInstancesReportOperations", + "storage_task_assignment_instances_report": "StorageTaskAssignmentInstancesReportOperations" + } +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_storage_management_client.py new file mode 100644 index 000000000000..cf6a3bc19465 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_storage_management_client.py @@ -0,0 +1,256 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +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 .._serialization import Deserializer, Serializer +from ._configuration import StorageManagementClientConfiguration +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + StorageTaskAssignmentInstancesReportOperations, + StorageTaskAssignmentsInstancesReportOperations, + StorageTaskAssignmentsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Azure Storage Management API. + + :ivar blob_services: BlobServicesOperations operations + :vartype blob_services: azure.mgmt.storage.v2023_05_01.operations.BlobServicesOperations + :ivar blob_containers: BlobContainersOperations operations + :vartype blob_containers: azure.mgmt.storage.v2023_05_01.operations.BlobContainersOperations + :ivar file_services: FileServicesOperations operations + :vartype file_services: azure.mgmt.storage.v2023_05_01.operations.FileServicesOperations + :ivar file_shares: FileSharesOperations operations + :vartype file_shares: azure.mgmt.storage.v2023_05_01.operations.FileSharesOperations + :ivar queue_services: QueueServicesOperations operations + :vartype queue_services: azure.mgmt.storage.v2023_05_01.operations.QueueServicesOperations + :ivar queue: QueueOperations operations + :vartype queue: azure.mgmt.storage.v2023_05_01.operations.QueueOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.storage.v2023_05_01.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.storage.v2023_05_01.operations.SkusOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: azure.mgmt.storage.v2023_05_01.operations.StorageAccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: azure.mgmt.storage.v2023_05_01.operations.DeletedAccountsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.storage.v2023_05_01.operations.UsagesOperations + :ivar management_policies: ManagementPoliciesOperations operations + :vartype management_policies: + azure.mgmt.storage.v2023_05_01.operations.ManagementPoliciesOperations + :ivar blob_inventory_policies: BlobInventoryPoliciesOperations operations + :vartype blob_inventory_policies: + azure.mgmt.storage.v2023_05_01.operations.BlobInventoryPoliciesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.storage.v2023_05_01.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.storage.v2023_05_01.operations.PrivateLinkResourcesOperations + :ivar object_replication_policies: ObjectReplicationPoliciesOperations operations + :vartype object_replication_policies: + azure.mgmt.storage.v2023_05_01.operations.ObjectReplicationPoliciesOperations + :ivar local_users: LocalUsersOperations operations + :vartype local_users: azure.mgmt.storage.v2023_05_01.operations.LocalUsersOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.storage.v2023_05_01.operations.EncryptionScopesOperations + :ivar table_services: TableServicesOperations operations + :vartype table_services: azure.mgmt.storage.v2023_05_01.operations.TableServicesOperations + :ivar table: TableOperations operations + :vartype table: azure.mgmt.storage.v2023_05_01.operations.TableOperations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.storage.v2023_05_01.operations.NetworkSecurityPerimeterConfigurationsOperations + :ivar storage_task_assignments: StorageTaskAssignmentsOperations operations + :vartype storage_task_assignments: + azure.mgmt.storage.v2023_05_01.operations.StorageTaskAssignmentsOperations + :ivar storage_task_assignments_instances_report: + StorageTaskAssignmentsInstancesReportOperations operations + :vartype storage_task_assignments_instances_report: + azure.mgmt.storage.v2023_05_01.operations.StorageTaskAssignmentsInstancesReportOperations + :ivar storage_task_assignment_instances_report: StorageTaskAssignmentInstancesReportOperations + operations + :vartype storage_task_assignment_instances_report: + azure.mgmt.storage.v2023_05_01.operations.StorageTaskAssignmentInstancesReportOperations + :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. 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 "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **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) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.storage_task_assignments = StorageTaskAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.storage_task_assignments_instances_report = StorageTaskAssignmentsInstancesReportOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.storage_task_assignment_instances_report = StorageTaskAssignmentInstancesReportOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + + 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 + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "StorageManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_version.py new file mode 100644 index 000000000000..da0ea07dff87 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "21.2.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/__init__.py new file mode 100644 index 000000000000..a5c3d2414cfd --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StorageManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_configuration.py new file mode 100644 index 000000000000..59974e3ace8f --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_configuration.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-05-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + 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-storage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.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( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_storage_management_client.py new file mode 100644 index 000000000000..ef0e17dc2ca3 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/_storage_management_client.py @@ -0,0 +1,261 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +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 StorageManagementClientConfiguration +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + StorageTaskAssignmentInstancesReportOperations, + StorageTaskAssignmentsInstancesReportOperations, + StorageTaskAssignmentsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Azure Storage Management API. + + :ivar blob_services: BlobServicesOperations operations + :vartype blob_services: azure.mgmt.storage.v2023_05_01.aio.operations.BlobServicesOperations + :ivar blob_containers: BlobContainersOperations operations + :vartype blob_containers: + azure.mgmt.storage.v2023_05_01.aio.operations.BlobContainersOperations + :ivar file_services: FileServicesOperations operations + :vartype file_services: azure.mgmt.storage.v2023_05_01.aio.operations.FileServicesOperations + :ivar file_shares: FileSharesOperations operations + :vartype file_shares: azure.mgmt.storage.v2023_05_01.aio.operations.FileSharesOperations + :ivar queue_services: QueueServicesOperations operations + :vartype queue_services: azure.mgmt.storage.v2023_05_01.aio.operations.QueueServicesOperations + :ivar queue: QueueOperations operations + :vartype queue: azure.mgmt.storage.v2023_05_01.aio.operations.QueueOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.storage.v2023_05_01.aio.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.storage.v2023_05_01.aio.operations.SkusOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: + azure.mgmt.storage.v2023_05_01.aio.operations.StorageAccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: + azure.mgmt.storage.v2023_05_01.aio.operations.DeletedAccountsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.storage.v2023_05_01.aio.operations.UsagesOperations + :ivar management_policies: ManagementPoliciesOperations operations + :vartype management_policies: + azure.mgmt.storage.v2023_05_01.aio.operations.ManagementPoliciesOperations + :ivar blob_inventory_policies: BlobInventoryPoliciesOperations operations + :vartype blob_inventory_policies: + azure.mgmt.storage.v2023_05_01.aio.operations.BlobInventoryPoliciesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.storage.v2023_05_01.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.storage.v2023_05_01.aio.operations.PrivateLinkResourcesOperations + :ivar object_replication_policies: ObjectReplicationPoliciesOperations operations + :vartype object_replication_policies: + azure.mgmt.storage.v2023_05_01.aio.operations.ObjectReplicationPoliciesOperations + :ivar local_users: LocalUsersOperations operations + :vartype local_users: azure.mgmt.storage.v2023_05_01.aio.operations.LocalUsersOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.storage.v2023_05_01.aio.operations.EncryptionScopesOperations + :ivar table_services: TableServicesOperations operations + :vartype table_services: azure.mgmt.storage.v2023_05_01.aio.operations.TableServicesOperations + :ivar table: TableOperations operations + :vartype table: azure.mgmt.storage.v2023_05_01.aio.operations.TableOperations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.storage.v2023_05_01.aio.operations.NetworkSecurityPerimeterConfigurationsOperations + :ivar storage_task_assignments: StorageTaskAssignmentsOperations operations + :vartype storage_task_assignments: + azure.mgmt.storage.v2023_05_01.aio.operations.StorageTaskAssignmentsOperations + :ivar storage_task_assignments_instances_report: + StorageTaskAssignmentsInstancesReportOperations operations + :vartype storage_task_assignments_instances_report: + azure.mgmt.storage.v2023_05_01.aio.operations.StorageTaskAssignmentsInstancesReportOperations + :ivar storage_task_assignment_instances_report: StorageTaskAssignmentInstancesReportOperations + operations + :vartype storage_task_assignment_instances_report: + azure.mgmt.storage.v2023_05_01.aio.operations.StorageTaskAssignmentInstancesReportOperations + :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. 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 "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **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) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize, "2023-05-01") + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.storage_task_assignments = StorageTaskAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.storage_task_assignments_instances_report = StorageTaskAssignmentsInstancesReportOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + self.storage_task_assignment_instances_report = StorageTaskAssignmentInstancesReportOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + + 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 + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + 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) -> "StorageManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/__init__.py new file mode 100644 index 000000000000..e62e153ac4a1 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/__init__.py @@ -0,0 +1,65 @@ +# 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 ._blob_services_operations import BlobServicesOperations +from ._blob_containers_operations import BlobContainersOperations +from ._file_services_operations import FileServicesOperations +from ._file_shares_operations import FileSharesOperations +from ._queue_services_operations import QueueServicesOperations +from ._queue_operations import QueueOperations +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._deleted_accounts_operations import DeletedAccountsOperations +from ._usages_operations import UsagesOperations +from ._management_policies_operations import ManagementPoliciesOperations +from ._blob_inventory_policies_operations import BlobInventoryPoliciesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._object_replication_policies_operations import ObjectReplicationPoliciesOperations +from ._local_users_operations import LocalUsersOperations +from ._encryption_scopes_operations import EncryptionScopesOperations +from ._table_services_operations import TableServicesOperations +from ._table_operations import TableOperations +from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations +from ._storage_task_assignments_operations import StorageTaskAssignmentsOperations +from ._storage_task_assignments_instances_report_operations import StorageTaskAssignmentsInstancesReportOperations +from ._storage_task_assignment_instances_report_operations import StorageTaskAssignmentInstancesReportOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "TableServicesOperations", + "TableOperations", + "NetworkSecurityPerimeterConfigurationsOperations", + "StorageTaskAssignmentsOperations", + "StorageTaskAssignmentsInstancesReportOperations", + "StorageTaskAssignmentInstancesReportOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_containers_operations.py new file mode 100644 index 000000000000..b9f45e4db5e4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_containers_operations.py @@ -0,0 +1,1838 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + 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]] + + +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`blob_containers` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ListContainerItem"]: + """Lists all containers and does not support a prefix like data plane. Also SRP today does not + return continuation token. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of containers that can be included in + the list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only container names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, used to include the properties for soft deleted blob containers. + "deleted" Default value is None. + :type include: str or ~azure.mgmt.storage.v2023_05_01.models.ListContainersInclude + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListContainerItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: 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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO[bytes]], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a BlobContainer + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer or IO[bytes] + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IOBase, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: 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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO[bytes]], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a BlobContainer + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer or IO[bytes] + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IOBase, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> _models.BlobContainer: + """Gets properties of a specified container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :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._api_version or "2023-05-01")) + cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + """Deletes specified container under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: 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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO[bytes]], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold or IO[bytes] + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LegalHold] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IOBase, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + _request = build_set_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: 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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO[bytes]], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold or IO[bytes] + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LegalHold] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IOBase, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + _request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy or IO[bytes] + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + _request = build_create_or_update_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Gets the existing immutability policy along with the corresponding ETag in response headers and + body. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + _request = build_get_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Aborts an unlocked immutability policy. The response of delete has + immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this + operation. Deleting a locked immutability policy is not allowed, the only way is to delete the + container after deleting all expired blobs inside the policy locked container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + _request = build_delete_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def lock_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is + ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + _request = build_lock_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy or IO[bytes] + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + _request = build_extend_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerRequest or IO[bytes] + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LeaseContainerResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None + + _request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_object_level_worm_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation migrates a blob container from container level WORM to object level immutability + enabled container. Prerequisites require a container level immutability policy either in locked + or unlocked state, Account level versioning must be enabled and there should be no Legal hold + on the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._object_level_worm_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_inventory_policies_operations.py new file mode 100644 index 000000000000..0fa7a978bdb8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_inventory_policies_operations.py @@ -0,0 +1,442 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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]] + + +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy or IO[bytes] + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> None: + """Deletes the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListBlobInventoryPolicy", 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) + + _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/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_services_operations.py new file mode 100644 index 000000000000..11bfbe35b07f --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_blob_services_operations.py @@ -0,0 +1,362 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_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]] + + +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`blob_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: + """List blob services of storage account. It returns a collection of one object named default. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BlobServiceItems", 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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties or IO[bytes] + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :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 = 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._api_version or "2023-05-01")) + blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.BlobServiceProperties: + """Gets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :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._api_version or "2023-05-01")) + blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") + cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_deleted_accounts_operations.py new file mode 100644 index 000000000000..9a75d7529c31 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_deleted_accounts_operations.py @@ -0,0 +1,194 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deleted_accounts_operations import build_get_request, 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]] + + +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: + """Lists deleted accounts under the subscription. + + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedAccountListResult", 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) + + @distributed_trace_async + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: + """Get properties of specified deleted account resource. + + :param deleted_account_name: Name of the deleted storage account. Required. + :type deleted_account_name: str + :param location: The location of the deleted storage account. Required. + :type location: str + :return: DeletedAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.DeletedAccount + :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._api_version or "2023-05-01")) + cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) + + _request = build_get_request( + deleted_account_name=deleted_account_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_encryption_scopes_operations.py new file mode 100644 index 000000000000..19118fc7b53a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_encryption_scopes_operations.py @@ -0,0 +1,568 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_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 EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: 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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope or IO[bytes] + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IOBase, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + _request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: 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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope or IO[bytes] + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IOBase, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + _request = build_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> _models.EncryptionScope: + """Returns the properties for the specified encryption scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :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._api_version or "2023-05-01")) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListEncryptionScopesInclude]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: + """Lists all the encryption scopes available under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of encryption scopes that will be + included in the list response. Default value is None. + :type maxpagesize: int + :param filter: Optional. When specified, only encryption scope names starting with the filter + will be listed. Default value is None. + :type filter: str + :param include: Optional, when specified, will list encryption scopes with the specific state. + Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. + :type include: str or ~azure.mgmt.storage.v2023_05_01.models.ListEncryptionScopesInclude + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EncryptionScopeListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_file_services_operations.py new file mode 100644 index 000000000000..b7eff2d9771a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_file_services_operations.py @@ -0,0 +1,328 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_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]] + + +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`file_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: + """List all file services in storage accounts. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: FileServiceItems or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceItems + :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._api_version or "2023-05-01")) + cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceItems", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties or IO[bytes] + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :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 = 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._api_version or "2023-05-01")) + file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.FileServiceProperties: + """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :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._api_version or "2023-05-01")) + file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") + cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_file_shares_operations.py new file mode 100644 index 000000000000..263ba0a63da7 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_file_shares_operations.py @@ -0,0 +1,1003 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + 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]] + + +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`file_shares` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.FileShareItem"]: + """Lists all shares. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of shares that can be included in the + list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only share names starting with the filter will be + listed. Default value is None. + :type filter: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. + :type expand: str + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FileShareItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO[bytes], + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO[bytes] + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO[bytes]], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare or IO[bytes] + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IOBase, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FileShare", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO[bytes]], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare or IO[bytes] + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IOBase, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + share_name: str, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Gets properties of a specified share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: stats. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. + :type x_ms_snapshot: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :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._api_version or "2023-05-01")) + cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + x_ms_snapshot=x_ms_snapshot, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes specified share under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. + :type x_ms_snapshot: str + :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default + value is snapshots. For 'snapshots', the file share is deleted including all of its file share + snapshots. If the file share contains leased-snapshots, the deletion fails. For + 'leased-snapshots', the file share is deleted included all of its file share snapshots + (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. + :type include: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: ~azure.mgmt.storage.v2023_05_01.models.DeletedShare + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO[bytes]], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2023_05_01.models.DeletedShare or IO[bytes] + :return: None or the result of cls(response) + :rtype: 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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IOBase, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") + + _request = build_restore_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareRequest or IO[bytes] + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LeaseShareResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None + + _request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_local_users_operations.py new file mode 100644 index 000000000000..d57fb96e944a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_local_users_operations.py @@ -0,0 +1,583 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._local_users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_keys_request, + build_list_request, + build_regenerate_password_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 LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`local_users` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListLocalUserIncludeParam]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LocalUser"]: + """List the local users associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of local users that will be included + in the list response. Default value is None. + :type maxpagesize: int + :param filter: Optional. When specified, only local user names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, when specified, will list local users enabled for the specific + protocol. Lists all users by default. "nfsv3" Default value is None. + :type include: str or ~azure.mgmt.storage.v2023_05_01.models.ListLocalUserIncludeParam + :return: An iterator like instance of either LocalUser or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LocalUsers", 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) + + _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) + + @distributed_trace_async + async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: + """Get the local user of the storage account by username. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :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._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: _models.LocalUser, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. Properties + for NFSv3 enablement and extended groups cannot be set with other properties. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. Properties + for NFSv3 enablement and extended groups cannot be set with other properties. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO[bytes]], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. Properties + for NFSv3 enablement and extended groups cannot be set with other properties. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a LocalUser type + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.LocalUser or IO[bytes] + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> None: + """Deletes the local user associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserKeys: + """List SSH authorized keys and shared key of the local user. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: LocalUserKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUserKeys + :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._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def regenerate_password( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserRegeneratePasswordResult: + """Regenerate the local user SSH password. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: LocalUserRegeneratePasswordResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUserRegeneratePasswordResult + :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._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) + + _request = build_regenerate_password_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_management_policies_operations.py new file mode 100644 index 000000000000..734fec88534a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_management_policies_operations.py @@ -0,0 +1,349 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._management_policies_operations import ( + build_create_or_update_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 ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`management_policies` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Gets the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy or IO[bytes] + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> None: + """Deletes the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_network_security_perimeter_configurations_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_network_security_perimeter_configurations_operations.py new file mode 100644 index 000000000000..a27e3ba1f437 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_network_security_perimeter_configurations_operations.py @@ -0,0 +1,342 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._network_security_perimeter_configurations_operations import ( + build_get_request, + build_list_request, + build_reconcile_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 NetworkSecurityPerimeterConfigurationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`network_security_perimeter_configurations` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets list of effective NetworkSecurityPerimeterConfiguration for storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfigurationList", 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) + + _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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets effective NetworkSecurityPerimeterConfiguration for association. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfiguration + :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._api_version or "2023-05-01")) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _reconcile_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_reconcile_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_reconcile( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refreshes any information about the association. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._reconcile_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_object_replication_policies_operations.py new file mode 100644 index 000000000000..73f95a92ffc6 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_object_replication_policies_operations.py @@ -0,0 +1,446 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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]] + + +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: + """List the object replication policies associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either ObjectReplicationPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ObjectReplicationPolicies", 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) + + _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) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Get the object replication policy of the storage account by policy ID. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy or IO[bytes] + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> None: + """Deletes the object replication policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_operations.py new file mode 100644 index 000000000000..7aa1c1baa1b0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_operations.py @@ -0,0 +1,135 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._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]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`operations` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available Storage Rest API operations. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.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", self._api_version or "2023-05-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..6a5828fa9867 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,432 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_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 PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List all the private endpoint connections associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :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._api_version or "2023-05-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection or IO[bytes] + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") + + _request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + """Deletes the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..e8dfc6f0cb42 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,117 @@ +# 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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_list_by_storage_account_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 PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_by_storage_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateLinkResourceListResult + :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._api_version or "2023-05-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_list_by_storage_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_queue_operations.py new file mode 100644 index 000000000000..983152d2a530 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_queue_operations.py @@ -0,0 +1,608 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + 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]] + + +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`queue` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: 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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO[bytes]], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue or IO[bytes] + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IOBase, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: 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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO[bytes]], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue or IO[bytes] + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IOBase, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any + ) -> _models.StorageQueue: + """Gets the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any + ) -> None: + """Deletes the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ListQueue"]: + """Gets a list of all the queues under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, a maximum number of queues that should be included in a list + queue response. Default value is None. + :type maxpagesize: str + :param filter: Optional, When specified, only the queues with a name starting with the given + filter will be listed. Default value is None. + :type filter: str + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListQueueResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_queue_services_operations.py new file mode 100644 index 000000000000..8e6414cf7729 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_queue_services_operations.py @@ -0,0 +1,328 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_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]] + + +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`queue_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: + """List all queue services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: ListQueueServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListQueueServices + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListQueueServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties or IO[bytes] + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :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 = 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._api_version or "2023-05-01")) + queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.QueueServiceProperties: + """Gets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :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._api_version or "2023-05-01")) + queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") + cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..8c33030e8b6b --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_skus_operations.py @@ -0,0 +1,136 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_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]] + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`skus` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: + """Lists the available SKUs supported by Microsoft.Storage for given subscription. + + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageSkuListResult", 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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..4894f9f5100a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_accounts_operations.py @@ -0,0 +1,2187 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_abort_hierarchical_namespace_migration_request, + build_check_name_availability_request, + build_create_request, + build_customer_initiated_migration_request, + build_delete_request, + build_failover_request, + build_get_customer_initiated_migration_request, + build_get_properties_request, + build_hierarchical_namespace_migration_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + 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]] + + +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + async def check_name_availability( + self, + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. + :type account_name: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.CheckNameAvailabilityResult + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IOBase, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") + + _request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :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 + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCreateParameters or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageAccount", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.StorageAccount].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_properties( + self, + resource_group_name: str, + account_name: str, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, + **kwargs: Any + ) -> _models.StorageAccount: + """Returns the properties for the specified storage account including but not limited to name, SKU + name, location, and account status. The ListKeys operation should be used to retrieve storage + keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: May be used to expand the properties within account's properties. By default, + data is not included when fetching properties. Currently we only support geoReplicationStats + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. + :type expand: str or ~azure.mgmt.storage.v2023_05_01.models.StorageAccountExpand + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + _request = build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountUpdateParameters or + IO[bytes] + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage + account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" and None. Default value is "kerb". + :type expand: str + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountRegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. + :type regenerate_key: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IOBase, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") + + _request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.AccountSasParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.AccountSasParameters or IO[bytes] + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListAccountSasResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ListAccountSasResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") + + _request = build_list_account_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ServiceSasParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ServiceSasParameters or IO[bytes] + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListServiceSasResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ListServiceSasResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") + + _request = build_list_service_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _failover_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_failover_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + failover_type=failover_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def begin_failover( + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> AsyncLROPoller[None]: + """A failover request can be triggered for a storage account in the event a primary endpoint + becomes unavailable for any reason. The failover occurs from the storage account's primary + cluster to the secondary cluster for RA-GRS accounts. The secondary cluster will become primary + after failover and the account is converted to LRS. In the case of a Planned Failover, the + primary and secondary clusters are swapped after failover and the account remains + geo-replicated. Failover should continue to be used in the event of availability issues as + Planned failover is only available while the primary and secondary endpoints are available. The + primary use case of a Planned Failover is disaster recovery testing drills. This type of + failover is invoked by setting FailoverType parameter to 'Planned'. Learn more about the + failover options here- + https://learn.microsoft.com/en-us/azure/storage/common/storage-disaster-recovery-guidance. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover + is requested. Known values are "Planned" and None. Default value is "Planned". + :type failover_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._failover_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + failover_type=failover_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + request_type=request_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param request_type: Required. Hierarchical namespace migration type can either be a + hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request + 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the + hydration request will migrate the account. Required. + :type request_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + request_type=request_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_abort_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Abort live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._abort_hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _customer_initiated_migration_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountMigration, IO[bytes]], + **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountMigration") + + _request = build_customer_initiated_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def begin_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountMigration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Account Migration request can be triggered for a storage account to change its redundancy + level. The migration updates the non-zonal redundant storage account to a zonal redundant + account or vice-versa in order to have better reliability and availability. Zone-redundant + storage (ZRS) replicates your storage account synchronously across three Azure availability + zones in the primary region. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The request parameters required to perform storage account migration. + Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMigration + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Account Migration request can be triggered for a storage account to change its redundancy + level. The migration updates the non-zonal redundant storage account to a zonal redundant + account or vice-versa in order to have better reliability and availability. Zone-redundant + storage (ZRS) replicates your storage account synchronously across three Azure availability + zones in the primary region. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The request parameters required to perform storage account migration. + Required. + :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 + :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: + """ + + @distributed_trace_async + async def begin_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountMigration, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Account Migration request can be triggered for a storage account to change its redundancy + level. The migration updates the non-zonal redundant storage account to a zonal redundant + account or vice-versa in order to have better reliability and availability. Zone-redundant + storage (ZRS) replicates your storage account synchronously across three Azure availability + zones in the primary region. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The request parameters required to perform storage account migration. Is + either a StorageAccountMigration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMigration or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._customer_initiated_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + migration_name: Union[str, _models.MigrationName], + **kwargs: Any + ) -> _models.StorageAccountMigration: + """Gets the status of the ongoing migration for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param migration_name: The name of the Storage Account Migration. It should always be + 'default'. "default" Required. + :type migration_name: str or ~azure.mgmt.storage.v2023_05_01.models.MigrationName + :return: StorageAccountMigration or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMigration + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountMigration] = kwargs.pop("cls", None) + + _request = build_get_customer_initiated_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountMigration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _restore_blob_ranges_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], + **kwargs: Any + ) -> _models.BlobRestoreStatus: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobRestoreStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") + + _request = build_restore_blob_ranges_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :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 + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobRestoreStatus] = 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_blob_ranges_initial( + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BlobRestoreStatus].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Revoke user delegation keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_revoke_user_delegation_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignment_instances_report_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignment_instances_report_operations.py new file mode 100644 index 000000000000..8eab739ad05a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignment_instances_report_operations.py @@ -0,0 +1,170 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storage_task_assignment_instances_report_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]] + + +class StorageTaskAssignmentInstancesReportOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`storage_task_assignment_instances_report` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.StorageTaskReportInstance"]: + """Fetch the report summary of a single storage task assignment's instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param maxpagesize: Optional, specifies the maximum number of storage task assignment instances + to be included in the list response. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, it can be used to query using reporting properties. + See `Constructing Filter Strings + `_ + for details. Default value is None. + :type filter: str + :return: An iterator like instance of either StorageTaskReportInstance or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskReportSummary] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageTaskReportSummary", 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignments_instances_report_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignments_instances_report_operations.py new file mode 100644 index 000000000000..df15170d037e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignments_instances_report_operations.py @@ -0,0 +1,164 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storage_task_assignments_instances_report_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]] + + +class StorageTaskAssignmentsInstancesReportOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`storage_task_assignments_instances_report` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.StorageTaskReportInstance"]: + """Fetch the report summary of all the storage task assignments and instances in an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of storage task assignment instances + to be included in the list response. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, it can be used to query using reporting properties. + See `Constructing Filter Strings + `_ + for details. Default value is None. + :type filter: str + :return: An iterator like instance of either StorageTaskReportInstance or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskReportSummary] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageTaskReportSummary", 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignments_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignments_operations.py new file mode 100644 index 000000000000..d2ecb21bc72f --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_storage_task_assignments_operations.py @@ -0,0 +1,802 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, 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 ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storage_task_assignments_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + 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]] + + +class StorageTaskAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`storage_task_assignments` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignment, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.StorageTaskAssignment]: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageTaskAssignment]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageTaskAssignment") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("StorageTaskAssignment", 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) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: _models.StorageTaskAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageTaskAssignment]: + """Asynchronously creates a new storage task assignment sub-resource with the specified + parameters. If a storage task assignment is already created and a subsequent create request is + issued with different properties, the storage task assignment properties will be updated. If a + storage task assignment is already created and a subsequent create or update request is issued + with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to create a Storage Task Assignment. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment + :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 StorageTaskAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageTaskAssignment]: + """Asynchronously creates a new storage task assignment sub-resource with the specified + parameters. If a storage task assignment is already created and a subsequent create request is + issued with different properties, the storage task assignment properties will be updated. If a + storage task assignment is already created and a subsequent create or update request is issued + with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to create a Storage Task Assignment. Required. + :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 + :return: An instance of AsyncLROPoller that returns either StorageTaskAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignment, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageTaskAssignment]: + """Asynchronously creates a new storage task assignment sub-resource with the specified + parameters. If a storage task assignment is already created and a subsequent create request is + issued with different properties, the storage task assignment properties will be updated. If a + storage task assignment is already created and a subsequent create or update request is issued + with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to create a Storage Task Assignment. Is either a + StorageTaskAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment or IO[bytes] + :return: An instance of AsyncLROPoller that returns either StorageTaskAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageTaskAssignment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.StorageTaskAssignment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.StorageTaskAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignmentUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.StorageTaskAssignment]: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageTaskAssignment]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageTaskAssignmentUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("StorageTaskAssignment", 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) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: _models.StorageTaskAssignmentUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageTaskAssignment]: + """Update storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to update a Storage Task Assignment. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateParameters + :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 StorageTaskAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageTaskAssignment]: + """Update storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to update a Storage Task Assignment. Required. + :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 + :return: An instance of AsyncLROPoller that returns either StorageTaskAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignmentUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageTaskAssignment]: + """Update storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to update a Storage Task Assignment. Is either a + StorageTaskAssignmentUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateParameters + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either StorageTaskAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageTaskAssignment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.StorageTaskAssignment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.StorageTaskAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, storage_task_assignment_name: str, **kwargs: Any + ) -> _models.StorageTaskAssignment: + """Get the storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :return: StorageTaskAssignment or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, storage_task_assignment_name: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, storage_task_assignment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the storage task assignment sub-resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, maxpagesize: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.StorageTaskAssignment"]: + """List all the storage task assignments in an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of storage task assignment Ids to be + included in the list response. Default value is None. + :type maxpagesize: str + :return: An iterator like instance of either StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskAssignmentsList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageTaskAssignmentsList", 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_table_operations.py new file mode 100644 index 000000000000..5a7587e7a961 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_table_operations.py @@ -0,0 +1,588 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + 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]] + + +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`table` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table or IO[bytes] + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Table] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table or IO[bytes] + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Table] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: + """Gets the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :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._api_version or "2023-05-01")) + cls: ClsType[_models.Table] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> None: + """Deletes the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: + """Gets a list of all the tables under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListTableResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_table_services_operations.py new file mode 100644 index 000000000000..3f74a2488877 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_table_services_operations.py @@ -0,0 +1,328 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_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]] + + +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`table_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: + """List all table services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: ListTableServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListTableServices + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListTableServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties or IO[bytes] + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :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 = 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._api_version or "2023-05-01")) + table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.TableServiceProperties: + """Gets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :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._api_version or "2023-05-01")) + table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") + cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_usages_operations.py new file mode 100644 index 000000000000..2cfe1b9f0a65 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/aio/operations/_usages_operations.py @@ -0,0 +1,139 @@ +# 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, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_location_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 UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.aio.StorageManagementClient`'s + :attr:`usages` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: + """Gets the current usage count and the limit for the resources of the location under the + subscription. + + :param location: The location of the Azure Storage resource. Required. + :type location: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2023_05_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UsageListResult", 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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/__init__.py new file mode 100644 index 000000000000..32d458c161b4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/__init__.py @@ -0,0 +1,537 @@ +# 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 ._models_py3 import AccessPolicy +from ._models_py3 import AccountImmutabilityPolicyProperties +from ._models_py3 import AccountSasParameters +from ._models_py3 import ActiveDirectoryProperties +from ._models_py3 import AzureEntityResource +from ._models_py3 import AzureFilesIdentityBasedAuthentication +from ._models_py3 import BlobContainer +from ._models_py3 import BlobInventoryCreationTime +from ._models_py3 import BlobInventoryPolicy +from ._models_py3 import BlobInventoryPolicyDefinition +from ._models_py3 import BlobInventoryPolicyFilter +from ._models_py3 import BlobInventoryPolicyRule +from ._models_py3 import BlobInventoryPolicySchema +from ._models_py3 import BlobRestoreParameters +from ._models_py3 import BlobRestoreRange +from ._models_py3 import BlobRestoreStatus +from ._models_py3 import BlobServiceItems +from ._models_py3 import BlobServiceProperties +from ._models_py3 import ChangeFeed +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import CloudErrorBody +from ._models_py3 import CorsRule +from ._models_py3 import CorsRules +from ._models_py3 import CustomDomain +from ._models_py3 import DateAfterCreation +from ._models_py3 import DateAfterModification +from ._models_py3 import DeleteRetentionPolicy +from ._models_py3 import DeletedAccount +from ._models_py3 import DeletedAccountListResult +from ._models_py3 import DeletedShare +from ._models_py3 import Dimension +from ._models_py3 import Encryption +from ._models_py3 import EncryptionIdentity +from ._models_py3 import EncryptionScope +from ._models_py3 import EncryptionScopeKeyVaultProperties +from ._models_py3 import EncryptionScopeListResult +from ._models_py3 import EncryptionService +from ._models_py3 import EncryptionServices +from ._models_py3 import Endpoints +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseAutoGenerated +from ._models_py3 import ErrorResponseBody +from ._models_py3 import ExecutionTarget +from ._models_py3 import ExecutionTrigger +from ._models_py3 import ExecutionTriggerUpdate +from ._models_py3 import ExtendedLocation +from ._models_py3 import FileServiceItems +from ._models_py3 import FileServiceProperties +from ._models_py3 import FileShare +from ._models_py3 import FileShareItem +from ._models_py3 import FileShareItems +from ._models_py3 import GeoReplicationStats +from ._models_py3 import IPRule +from ._models_py3 import Identity +from ._models_py3 import ImmutabilityPolicy +from ._models_py3 import ImmutabilityPolicyProperties +from ._models_py3 import ImmutableStorageAccount +from ._models_py3 import ImmutableStorageWithVersioning +from ._models_py3 import KeyCreationTime +from ._models_py3 import KeyPolicy +from ._models_py3 import KeyVaultProperties +from ._models_py3 import LastAccessTimeTrackingPolicy +from ._models_py3 import LeaseContainerRequest +from ._models_py3 import LeaseContainerResponse +from ._models_py3 import LeaseShareRequest +from ._models_py3 import LeaseShareResponse +from ._models_py3 import LegalHold +from ._models_py3 import LegalHoldProperties +from ._models_py3 import ListAccountSasResponse +from ._models_py3 import ListBlobInventoryPolicy +from ._models_py3 import ListContainerItem +from ._models_py3 import ListContainerItems +from ._models_py3 import ListQueue +from ._models_py3 import ListQueueResource +from ._models_py3 import ListQueueServices +from ._models_py3 import ListServiceSasResponse +from ._models_py3 import ListTableResource +from ._models_py3 import ListTableServices +from ._models_py3 import LocalUser +from ._models_py3 import LocalUserKeys +from ._models_py3 import LocalUserRegeneratePasswordResult +from ._models_py3 import LocalUsers +from ._models_py3 import ManagementPolicy +from ._models_py3 import ManagementPolicyAction +from ._models_py3 import ManagementPolicyBaseBlob +from ._models_py3 import ManagementPolicyDefinition +from ._models_py3 import ManagementPolicyFilter +from ._models_py3 import ManagementPolicyRule +from ._models_py3 import ManagementPolicySchema +from ._models_py3 import ManagementPolicySnapShot +from ._models_py3 import ManagementPolicyVersion +from ._models_py3 import MetricSpecification +from ._models_py3 import Multichannel +from ._models_py3 import NetworkRuleSet +from ._models_py3 import NetworkSecurityPerimeter +from ._models_py3 import NetworkSecurityPerimeterConfiguration +from ._models_py3 import NetworkSecurityPerimeterConfigurationList +from ._models_py3 import NetworkSecurityPerimeterConfigurationPropertiesProfile +from ._models_py3 import NetworkSecurityPerimeterConfigurationPropertiesResourceAssociation +from ._models_py3 import NspAccessRule +from ._models_py3 import NspAccessRuleProperties +from ._models_py3 import NspAccessRulePropertiesSubscriptionsItem +from ._models_py3 import ObjectReplicationPolicies +from ._models_py3 import ObjectReplicationPolicy +from ._models_py3 import ObjectReplicationPolicyFilter +from ._models_py3 import ObjectReplicationPolicyRule +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PermissionScope +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProtectedAppendWritesHistory +from ._models_py3 import ProtocolSettings +from ._models_py3 import ProvisioningIssue +from ._models_py3 import ProvisioningIssueProperties +from ._models_py3 import ProxyResource +from ._models_py3 import ProxyResourceAutoGenerated +from ._models_py3 import QueueServiceProperties +from ._models_py3 import Resource +from ._models_py3 import ResourceAccessRule +from ._models_py3 import ResourceAutoGenerated +from ._models_py3 import RestorePolicyProperties +from ._models_py3 import Restriction +from ._models_py3 import RoutingPreference +from ._models_py3 import SKUCapability +from ._models_py3 import SasPolicy +from ._models_py3 import ServiceSasParameters +from ._models_py3 import ServiceSpecification +from ._models_py3 import SignedIdentifier +from ._models_py3 import Sku +from ._models_py3 import SkuInformation +from ._models_py3 import SmbSetting +from ._models_py3 import SshPublicKey +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCheckNameAvailabilityParameters +from ._models_py3 import StorageAccountCreateParameters +from ._models_py3 import StorageAccountInternetEndpoints +from ._models_py3 import StorageAccountKey +from ._models_py3 import StorageAccountListKeysResult +from ._models_py3 import StorageAccountListResult +from ._models_py3 import StorageAccountMicrosoftEndpoints +from ._models_py3 import StorageAccountMigration +from ._models_py3 import StorageAccountRegenerateKeyParameters +from ._models_py3 import StorageAccountSkuConversionStatus +from ._models_py3 import StorageAccountUpdateParameters +from ._models_py3 import StorageQueue +from ._models_py3 import StorageSkuListResult +from ._models_py3 import StorageTaskAssignment +from ._models_py3 import StorageTaskAssignmentExecutionContext +from ._models_py3 import StorageTaskAssignmentProperties +from ._models_py3 import StorageTaskAssignmentReport +from ._models_py3 import StorageTaskAssignmentUpdateExecutionContext +from ._models_py3 import StorageTaskAssignmentUpdateParameters +from ._models_py3 import StorageTaskAssignmentUpdateProperties +from ._models_py3 import StorageTaskAssignmentUpdateReport +from ._models_py3 import StorageTaskAssignmentsList +from ._models_py3 import StorageTaskReportInstance +from ._models_py3 import StorageTaskReportProperties +from ._models_py3 import StorageTaskReportSummary +from ._models_py3 import SystemData +from ._models_py3 import Table +from ._models_py3 import TableAccessPolicy +from ._models_py3 import TableServiceProperties +from ._models_py3 import TableSignedIdentifier +from ._models_py3 import TagFilter +from ._models_py3 import TagProperty +from ._models_py3 import TrackedResource +from ._models_py3 import TriggerParameters +from ._models_py3 import TriggerParametersUpdate +from ._models_py3 import UpdateHistoryProperty +from ._models_py3 import Usage +from ._models_py3 import UsageListResult +from ._models_py3 import UsageName +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import VirtualNetworkRule + +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountImmutabilityPolicyState +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import AccountType +from ._storage_management_client_enums import AllowedCopyScope +from ._storage_management_client_enums import AllowedMethods +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import DnsEndpointType +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import IssueType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestEnum +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ListEncryptionScopesInclude +from ._storage_management_client_enums import ListLocalUserIncludeParam +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MigrationStatus +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import NetworkSecurityPerimeterConfigurationProvisioningState +from ._storage_management_client_enums import NspAccessRuleDirection +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PostFailoverRedundancy +from ._storage_management_client_enums import PostPlannedFailoverRedundancy +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PublicNetworkAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import ResourceAssociationAccessMode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import RunResult +from ._storage_management_client_enums import RunStatusEnum +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import Severity +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuConversionStatus +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import TriggerType +from ._storage_management_client_enums import UsageUnit +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AccessPolicy", + "AccountImmutabilityPolicyProperties", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryCreationTime", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "ErrorResponseBody", + "ExecutionTarget", + "ExecutionTrigger", + "ExecutionTriggerUpdate", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageAccount", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "LocalUser", + "LocalUserKeys", + "LocalUserRegeneratePasswordResult", + "LocalUsers", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "NetworkSecurityPerimeter", + "NetworkSecurityPerimeterConfiguration", + "NetworkSecurityPerimeterConfigurationList", + "NetworkSecurityPerimeterConfigurationPropertiesProfile", + "NetworkSecurityPerimeterConfigurationPropertiesResourceAssociation", + "NspAccessRule", + "NspAccessRuleProperties", + "NspAccessRulePropertiesSubscriptionsItem", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PermissionScope", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtectedAppendWritesHistory", + "ProtocolSettings", + "ProvisioningIssue", + "ProvisioningIssueProperties", + "ProxyResource", + "ProxyResourceAutoGenerated", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "ResourceAutoGenerated", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "SshPublicKey", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountMigration", + "StorageAccountRegenerateKeyParameters", + "StorageAccountSkuConversionStatus", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "StorageTaskAssignment", + "StorageTaskAssignmentExecutionContext", + "StorageTaskAssignmentProperties", + "StorageTaskAssignmentReport", + "StorageTaskAssignmentUpdateExecutionContext", + "StorageTaskAssignmentUpdateParameters", + "StorageTaskAssignmentUpdateProperties", + "StorageTaskAssignmentUpdateReport", + "StorageTaskAssignmentsList", + "StorageTaskReportInstance", + "StorageTaskReportProperties", + "StorageTaskReportSummary", + "SystemData", + "Table", + "TableAccessPolicy", + "TableServiceProperties", + "TableSignedIdentifier", + "TagFilter", + "TagProperty", + "TrackedResource", + "TriggerParameters", + "TriggerParametersUpdate", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountImmutabilityPolicyState", + "AccountStatus", + "AccountType", + "AllowedCopyScope", + "AllowedMethods", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "DnsEndpointType", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "IssueType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestEnum", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ListEncryptionScopesInclude", + "ListLocalUserIncludeParam", + "ManagementPolicyName", + "MigrationName", + "MigrationState", + "MigrationStatus", + "MinimumTlsVersion", + "Name", + "NetworkSecurityPerimeterConfigurationProvisioningState", + "NspAccessRuleDirection", + "ObjectType", + "Permissions", + "PostFailoverRedundancy", + "PostPlannedFailoverRedundancy", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PublicNetworkAccess", + "Reason", + "ReasonCode", + "ResourceAssociationAccessMode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "RunResult", + "RunStatusEnum", + "Schedule", + "Services", + "Severity", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuConversionStatus", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "TriggerType", + "UsageUnit", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_models_py3.py new file mode 100644 index 000000000000..c74c33699dcf --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_models_py3.py @@ -0,0 +1,9703 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class AccessPolicy(_serialization.Model): + """AccessPolicy. + + :ivar start_time: Start time of the access policy. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Expiry time of the access policy. + :vartype expiry_time: ~datetime.datetime + :ivar permission: List of abbreviated permissions. + :vartype permission: str + """ + + _attribute_map = { + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, + } + + def __init__( + self, + *, + start_time: Optional[datetime.datetime] = None, + expiry_time: Optional[datetime.datetime] = None, + permission: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_time: Start time of the access policy. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Expiry time of the access policy. + :paramtype expiry_time: ~datetime.datetime + :keyword permission: List of abbreviated permissions. + :paramtype permission: str + """ + super().__init__(**kwargs) + self.start_time = start_time + self.expiry_time = expiry_time + self.permission = permission + + +class AccountImmutabilityPolicyProperties(_serialization.Model): + """This defines account-level immutability policy properties. + + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state defines the mode of the policy. Disabled state + disables the policy, Unlocked state allows increase and decrease of immutability retention time + and also allows toggling allowProtectedAppendWrites property, Locked state only allows the + increase of the immutability retention time. A policy can only be created in a Disabled or + Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", + "Locked", and "Disabled". + :vartype state: str or ~azure.mgmt.storage.v2023_05_01.models.AccountImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for disabled and + unlocked time-based retention policies. When enabled, new blocks can be written to an append + blob while maintaining immutability protection and compliance. Only new blocks can be added and + any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes: bool + """ + + _validation = { + "immutability_period_since_creation_in_days": {"maximum": 146000, "minimum": 1}, + } + + _attribute_map = { + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "state": {"key": "state", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + state: Optional[Union[str, "_models.AccountImmutabilityPolicyState"]] = None, + allow_protected_append_writes: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword state: The ImmutabilityPolicy state defines the mode of the policy. Disabled state + disables the policy, Unlocked state allows increase and decrease of immutability retention time + and also allows toggling allowProtectedAppendWrites property, Locked state only allows the + increase of the immutability retention time. A policy can only be created in a Disabled or + Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", + "Locked", and "Disabled". + :paramtype state: str or ~azure.mgmt.storage.v2023_05_01.models.AccountImmutabilityPolicyState + :keyword allow_protected_append_writes: This property can only be changed for disabled and + unlocked time-based retention policies. When enabled, new blocks can be written to an append + blob while maintaining immutability protection and compliance. Only new blocks can be added and + any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes: bool + """ + super().__init__(**kwargs) + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = state + self.allow_protected_append_writes = allow_protected_append_writes + + +class AccountSasParameters(_serialization.Model): + """The parameters to list SAS credentials of a storage account. + + All required parameters must be populated in order to send to server. + + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". + :vartype services: str or ~azure.mgmt.storage.v2023_05_01.models.Services + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". + :vartype resource_types: str or ~azure.mgmt.storage.v2023_05_01.models.SignedResourceTypes + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :vartype permissions: str or ~azure.mgmt.storage.v2023_05_01.models.Permissions + :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :vartype ip_address_or_range: str + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http" and "https". + :vartype protocols: str or ~azure.mgmt.storage.v2023_05_01.models.HttpProtocol + :ivar shared_access_start_time: The time at which the SAS becomes valid. + :vartype shared_access_start_time: ~datetime.datetime + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. + :vartype shared_access_expiry_time: ~datetime.datetime + :ivar key_to_sign: The key to sign the account SAS token with. + :vartype key_to_sign: str + """ + + _validation = { + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, + } + + _attribute_map = { + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + } + + def __init__( + self, + *, + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], + shared_access_expiry_time: datetime.datetime, + ip_address_or_range: Optional[str] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, + shared_access_start_time: Optional[datetime.datetime] = None, + key_to_sign: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". + :paramtype services: str or ~azure.mgmt.storage.v2023_05_01.models.Services + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". + :paramtype resource_types: str or ~azure.mgmt.storage.v2023_05_01.models.SignedResourceTypes + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :paramtype permissions: str or ~azure.mgmt.storage.v2023_05_01.models.Permissions + :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :paramtype ip_address_or_range: str + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http" and "https". + :paramtype protocols: str or ~azure.mgmt.storage.v2023_05_01.models.HttpProtocol + :keyword shared_access_start_time: The time at which the SAS becomes valid. + :paramtype shared_access_start_time: ~datetime.datetime + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. + :paramtype shared_access_expiry_time: ~datetime.datetime + :keyword key_to_sign: The key to sign the account SAS token with. + :paramtype key_to_sign: str + """ + super().__init__(**kwargs) + self.services = services + self.resource_types = resource_types + self.permissions = permissions + self.ip_address_or_range = ip_address_or_range + self.protocols = protocols + self.shared_access_start_time = shared_access_start_time + self.shared_access_expiry_time = shared_access_expiry_time + self.key_to_sign = key_to_sign + + +class ActiveDirectoryProperties(_serialization.Model): + """Settings properties for Active Directory (AD). + + All required parameters must be populated in order to send to server. + + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. + :vartype domain_name: str + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. + :vartype net_bios_domain_name: str + :ivar forest_name: Specifies the Active Directory forest to get. + :vartype forest_name: str + :ivar domain_guid: Specifies the domain GUID. Required. + :vartype domain_guid: str + :ivar domain_sid: Specifies the security identifier (SID). + :vartype domain_sid: str + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + :vartype azure_storage_sid: str + :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. + :vartype sam_account_name: str + :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values + are: "User" and "Computer". + :vartype account_type: str or ~azure.mgmt.storage.v2023_05_01.models.AccountType + """ + + _validation = { + "domain_name": {"required": True}, + "domain_guid": {"required": True}, + } + + _attribute_map = { + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, + "sam_account_name": {"key": "samAccountName", "type": "str"}, + "account_type": {"key": "accountType", "type": "str"}, + } + + def __init__( + self, + *, + domain_name: str, + domain_guid: str, + net_bios_domain_name: Optional[str] = None, + forest_name: Optional[str] = None, + domain_sid: Optional[str] = None, + azure_storage_sid: Optional[str] = None, + sam_account_name: Optional[str] = None, + account_type: Optional[Union[str, "_models.AccountType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. + :paramtype domain_name: str + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. + :paramtype net_bios_domain_name: str + :keyword forest_name: Specifies the Active Directory forest to get. + :paramtype forest_name: str + :keyword domain_guid: Specifies the domain GUID. Required. + :paramtype domain_guid: str + :keyword domain_sid: Specifies the security identifier (SID). + :paramtype domain_sid: str + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + :paramtype azure_storage_sid: str + :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. + :paramtype sam_account_name: str + :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known + values are: "User" and "Computer". + :paramtype account_type: str or ~azure.mgmt.storage.v2023_05_01.models.AccountType + """ + super().__init__(**kwargs) + self.domain_name = domain_name + self.net_bios_domain_name = net_bios_domain_name + self.forest_name = forest_name + self.domain_guid = domain_guid + self.domain_sid = domain_sid + self.azure_storage_sid = azure_storage_sid + self.sam_account_name = sam_account_name + self.account_type = account_type + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class AzureEntityResource(Resource): + """The resource model definition for an Azure Resource Manager resource with an etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.etag = None + + +class AzureFilesIdentityBasedAuthentication(_serialization.Model): + """Settings for Azure Files identity based authentication. + + All required parameters must be populated in order to send to server. + + :ivar directory_service_options: Indicates the directory service used. Note that this enum may + be extended in the future. Required. Known values are: "None", "AADDS", "AD", and "AADKERB". + :vartype directory_service_options: str or + ~azure.mgmt.storage.v2023_05_01.models.DirectoryServiceOptions + :ivar active_directory_properties: Required if directoryServiceOptions are AD, optional if they + are AADKERB. + :vartype active_directory_properties: + ~azure.mgmt.storage.v2023_05_01.models.ActiveDirectoryProperties + :ivar default_share_permission: Default share permission for users using Kerberos + authentication if RBAC role is not assigned. Known values are: "None", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and + "StorageFileDataSmbShareElevatedContributor". + :vartype default_share_permission: str or + ~azure.mgmt.storage.v2023_05_01.models.DefaultSharePermission + """ + + _validation = { + "directory_service_options": {"required": True}, + } + + _attribute_map = { + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, + } + + def __init__( + self, + *, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword directory_service_options: Indicates the directory service used. Note that this enum + may be extended in the future. Required. Known values are: "None", "AADDS", "AD", and + "AADKERB". + :paramtype directory_service_options: str or + ~azure.mgmt.storage.v2023_05_01.models.DirectoryServiceOptions + :keyword active_directory_properties: Required if directoryServiceOptions are AD, optional if + they are AADKERB. + :paramtype active_directory_properties: + ~azure.mgmt.storage.v2023_05_01.models.ActiveDirectoryProperties + :keyword default_share_permission: Default share permission for users using Kerberos + authentication if RBAC role is not assigned. Known values are: "None", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and + "StorageFileDataSmbShareElevatedContributor". + :paramtype default_share_permission: str or + ~azure.mgmt.storage.v2023_05_01.models.DefaultSharePermission + """ + super().__init__(**kwargs) + self.directory_service_options = directory_service_options + self.active_directory_properties = active_directory_properties + self.default_share_permission = default_share_permission + + +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """Properties of the blob container, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar version: The version of the deleted blob container. + :vartype version: str + :ivar deleted: Indicates whether the blob container was deleted. + :vartype deleted: bool + :ivar deleted_time: Blob container deletion time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for soft deleted blob container. + :vartype remaining_retention_days: int + :ivar default_encryption_scope: Default the container to use specified encryption scope for all + writes. + :vartype default_encryption_scope: str + :ivar deny_encryption_scope_override: Block override of encryption scope from the container + default. + :vartype deny_encryption_scope_override: bool + :ivar public_access: Specifies whether data in the container may be accessed publicly and the + level of access. Known values are: "Container", "Blob", and "None". + :vartype public_access: str or ~azure.mgmt.storage.v2023_05_01.models.PublicAccess + :ivar last_modified_time: Returns the date and time the container was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseDuration + :ivar metadata: A name-value pair to associate with the container as metadata. + :vartype metadata: dict[str, str] + :ivar immutability_policy: The ImmutabilityPolicy property of the container. + :vartype immutability_policy: + ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicyProperties + :ivar legal_hold: The LegalHold property of the container. + :vartype legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHoldProperties + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar has_immutability_policy: The hasImmutabilityPolicy public property is set to true by SRP + if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public + property is set to false by SRP if ImmutabilityPolicy has not been created for this container. + :vartype has_immutability_policy: bool + :ivar immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageWithVersioning + :ivar enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :vartype enable_nfs_v3_root_squash: bool + :ivar enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :vartype enable_nfs_v3_all_squash: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, + } + + def __init__( + self, + *, + default_encryption_scope: Optional[str] = None, + deny_encryption_scope_override: Optional[bool] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, + metadata: Optional[Dict[str, str]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, + enable_nfs_v3_root_squash: Optional[bool] = None, + enable_nfs_v3_all_squash: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword default_encryption_scope: Default the container to use specified encryption scope for + all writes. + :paramtype default_encryption_scope: str + :keyword deny_encryption_scope_override: Block override of encryption scope from the container + default. + :paramtype deny_encryption_scope_override: bool + :keyword public_access: Specifies whether data in the container may be accessed publicly and + the level of access. Known values are: "Container", "Blob", and "None". + :paramtype public_access: str or ~azure.mgmt.storage.v2023_05_01.models.PublicAccess + :keyword metadata: A name-value pair to associate with the container as metadata. + :paramtype metadata: dict[str, str] + :keyword immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageWithVersioning + :keyword enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :paramtype enable_nfs_v3_root_squash: bool + :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :paramtype enable_nfs_v3_all_squash: bool + """ + super().__init__(**kwargs) + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.default_encryption_scope = default_encryption_scope + self.deny_encryption_scope_override = deny_encryption_scope_override + self.public_access = public_access + self.last_modified_time = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.metadata = metadata + self.immutability_policy = None + self.legal_hold = None + self.has_legal_hold = None + self.has_immutability_policy = None + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.enable_nfs_v3_root_squash = enable_nfs_v3_root_squash + self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash + + +class BlobInventoryCreationTime(_serialization.Model): + """This property defines the creation time based filtering condition. Blob Inventory schema + parameter 'Creation-Time' is mandatory with this filter. + + :ivar last_n_days: When set the policy filters the objects that are created in the last N days. + Where N is an integer value between 1 to 36500. + :vartype last_n_days: int + """ + + _validation = { + "last_n_days": {"maximum": 36500, "minimum": 1}, + } + + _attribute_map = { + "last_n_days": {"key": "lastNDays", "type": "int"}, + } + + def __init__(self, *, last_n_days: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword last_n_days: When set the policy filters the objects that are created in the last N + days. Where N is an integer value between 1 to 36500. + :paramtype last_n_days: int + """ + super().__init__(**kwargs) + self.last_n_days = last_n_days + + +class BlobInventoryPolicy(Resource): + """The storage account blob inventory policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.storage.v2023_05_01.models.SystemData + :ivar last_modified_time: Returns the last modified date and time of the blob inventory policy. + :vartype last_modified_time: ~datetime.datetime + :ivar policy: The storage account blob inventory policy object. It is composed of policy rules. + :vartype policy: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicySchema + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, + } + + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs: Any) -> None: + """ + :keyword policy: The storage account blob inventory policy object. It is composed of policy + rules. + :paramtype policy: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicySchema + """ + super().__init__(**kwargs) + self.system_data = None + self.last_modified_time = None + self.policy = policy + + +class BlobInventoryPolicyDefinition(_serialization.Model): + """An object that defines the blob inventory rule. + + All required parameters must be populated in order to send to server. + + :ivar filters: An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyFilter + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". + :vartype format: str or ~azure.mgmt.storage.v2023_05_01.models.Format + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". + :vartype schedule: str or ~azure.mgmt.storage.v2023_05_01.models.Schedule + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". + :vartype object_type: str or ~azure.mgmt.storage.v2023_05_01.models.ObjectType + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, + Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, + ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, + LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, + RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, + CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, + CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, + EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value + 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' + definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, + LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, + DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, + DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, + Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. + :vartype schema_fields: list[str] + """ + + _validation = { + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, + } + + _attribute_map = { + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, + } + + def __init__( + self, + *, + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], + schema_fields: List[str], + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, + **kwargs: Any + ) -> None: + """ + :keyword filters: An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyFilter + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". + :paramtype format: str or ~azure.mgmt.storage.v2023_05_01.models.Format + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". + :paramtype schedule: str or ~azure.mgmt.storage.v2023_05_01.models.Schedule + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". + :paramtype object_type: str or ~azure.mgmt.storage.v2023_05_01.models.ObjectType + :keyword schema_fields: This is a required field. This field specifies the fields and + properties of the object to be included in the inventory. The Schema field value 'Name' is + always required. The valid values for this field for the 'Blob' definition.objectType include + 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, + Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, + ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, + LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, + RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, + CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, + CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, + EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value + 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' + definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, + LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, + DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, + DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, + Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. + :paramtype schema_fields: list[str] + """ + super().__init__(**kwargs) + self.filters = filters + self.format = format + self.schedule = schedule + self.object_type = object_type + self.schema_fields = schema_fields + + +class BlobInventoryPolicyFilter(_serialization.Model): + """An object that defines the blob inventory rule filter conditions. For 'Blob' + definition.objectType all filter properties are applicable, 'blobTypes' is required and others + are optional. For 'Container' definition.objectType only prefixMatch is applicable and is + optional. + + :ivar prefix_match: An array of strings with maximum 10 blob prefixes to be included in the + inventory. + :vartype prefix_match: list[str] + :ivar exclude_prefix: An array of strings with maximum 10 blob prefixes to be excluded from the + inventory. + :vartype exclude_prefix: list[str] + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when + definition.objectType property is set to 'Blob'. + :vartype blob_types: list[str] + :ivar include_blob_versions: Includes blob versions in blob inventory when value is set to + true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this + property is set to true, else they must be excluded. + :vartype include_blob_versions: bool + :ivar include_snapshots: Includes blob snapshots in blob inventory when value is set to true. + The definition.schemaFields value 'Snapshot' is required if this property is set to true, else + it must be excluded. + :vartype include_snapshots: bool + :ivar include_deleted: For 'Container' definition.objectType the definition.schemaFields must + include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' + definition.objectType and HNS enabled storage accounts the definition.schemaFields must include + 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the + definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be + excluded. + :vartype include_deleted: bool + :ivar creation_time: This property is used to filter objects based on the object creation time. + :vartype creation_time: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryCreationTime + """ + + _attribute_map = { + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "exclude_prefix": {"key": "excludePrefix", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, + "include_deleted": {"key": "includeDeleted", "type": "bool"}, + "creation_time": {"key": "creationTime", "type": "BlobInventoryCreationTime"}, + } + + def __init__( + self, + *, + prefix_match: Optional[List[str]] = None, + exclude_prefix: Optional[List[str]] = None, + blob_types: Optional[List[str]] = None, + include_blob_versions: Optional[bool] = None, + include_snapshots: Optional[bool] = None, + include_deleted: Optional[bool] = None, + creation_time: Optional["_models.BlobInventoryCreationTime"] = None, + **kwargs: Any + ) -> None: + """ + :keyword prefix_match: An array of strings with maximum 10 blob prefixes to be included in the + inventory. + :paramtype prefix_match: list[str] + :keyword exclude_prefix: An array of strings with maximum 10 blob prefixes to be excluded from + the inventory. + :paramtype exclude_prefix: list[str] + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when + definition.objectType property is set to 'Blob'. + :paramtype blob_types: list[str] + :keyword include_blob_versions: Includes blob versions in blob inventory when value is set to + true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this + property is set to true, else they must be excluded. + :paramtype include_blob_versions: bool + :keyword include_snapshots: Includes blob snapshots in blob inventory when value is set to + true. The definition.schemaFields value 'Snapshot' is required if this property is set to true, + else it must be excluded. + :paramtype include_snapshots: bool + :keyword include_deleted: For 'Container' definition.objectType the definition.schemaFields + must include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' + definition.objectType and HNS enabled storage accounts the definition.schemaFields must include + 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the + definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be + excluded. + :paramtype include_deleted: bool + :keyword creation_time: This property is used to filter objects based on the object creation + time. + :paramtype creation_time: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryCreationTime + """ + super().__init__(**kwargs) + self.prefix_match = prefix_match + self.exclude_prefix = exclude_prefix + self.blob_types = blob_types + self.include_blob_versions = include_blob_versions + self.include_snapshots = include_snapshots + self.include_deleted = include_deleted + self.creation_time = creation_time + + +class BlobInventoryPolicyRule(_serialization.Model): + """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. + + All required parameters must be populated in order to send to server. + + :ivar enabled: Rule is enabled when set to true. Required. + :vartype enabled: bool + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. + :vartype name: str + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. + :vartype destination: str + :ivar definition: An object that defines the blob inventory policy rule. Required. + :vartype definition: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyDefinition + """ + + _validation = { + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, + } + + def __init__( + self, + *, + enabled: bool, + name: str, + destination: str, + definition: "_models.BlobInventoryPolicyDefinition", + **kwargs: Any + ) -> None: + """ + :keyword enabled: Rule is enabled when set to true. Required. + :paramtype enabled: bool + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. + :paramtype name: str + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. + :paramtype destination: str + :keyword definition: An object that defines the blob inventory policy rule. Required. + :paramtype definition: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyDefinition + """ + super().__init__(**kwargs) + self.enabled = enabled + self.name = name + self.destination = destination + self.definition = definition + + +class BlobInventoryPolicySchema(_serialization.Model): + """The storage account blob inventory policy rules. + + 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 enabled: Policy is enabled if set to true. Required. + :vartype enabled: bool + :ivar destination: Deprecated Property from API version 2021-04-01 onwards, the required + destination container name must be specified at the rule level 'policy.rule.destination'. + :vartype destination: str + :ivar type: The valid value is Inventory. Required. "Inventory" + :vartype type: str or ~azure.mgmt.storage.v2023_05_01.models.InventoryRuleType + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. + :vartype rules: list[~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyRule] + """ + + _validation = { + "enabled": {"required": True}, + "destination": {"readonly": True}, + "type": {"required": True}, + "rules": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, + } + + def __init__( + self, + *, + enabled: bool, + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], + **kwargs: Any + ) -> None: + """ + :keyword enabled: Policy is enabled if set to true. Required. + :paramtype enabled: bool + :keyword type: The valid value is Inventory. Required. "Inventory" + :paramtype type: str or ~azure.mgmt.storage.v2023_05_01.models.InventoryRuleType + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. + :paramtype rules: list[~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyRule] + """ + super().__init__(**kwargs) + self.enabled = enabled + self.destination = None + self.type = type + self.rules = rules + + +class BlobRestoreParameters(_serialization.Model): + """Blob restore parameters. + + All required parameters must be populated in order to send to server. + + :ivar time_to_restore: Restore blob to the specified time. Required. + :vartype time_to_restore: ~datetime.datetime + :ivar blob_ranges: Blob ranges to restore. Required. + :vartype blob_ranges: list[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreRange] + """ + + _validation = { + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, + } + + _attribute_map = { + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, + } + + def __init__( + self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs: Any + ) -> None: + """ + :keyword time_to_restore: Restore blob to the specified time. Required. + :paramtype time_to_restore: ~datetime.datetime + :keyword blob_ranges: Blob ranges to restore. Required. + :paramtype blob_ranges: list[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreRange] + """ + super().__init__(**kwargs) + self.time_to_restore = time_to_restore + self.blob_ranges = blob_ranges + + +class BlobRestoreRange(_serialization.Model): + """Blob range. + + All required parameters must be populated in order to send to server. + + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. + :vartype start_range: str + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. + :vartype end_range: str + """ + + _validation = { + "start_range": {"required": True}, + "end_range": {"required": True}, + } + + _attribute_map = { + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, + } + + def __init__(self, *, start_range: str, end_range: str, **kwargs: Any) -> None: + """ + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. + :paramtype start_range: str + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. + :paramtype end_range: str + """ + super().__init__(**kwargs) + self.start_range = start_range + self.end_range = end_range + + +class BlobRestoreStatus(_serialization.Model): + """Blob restore status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates + that blob restore is ongoing. - Complete: Indicates that blob restore has been completed + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", and "Failed". + :vartype status: str or ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreProgressStatus + :ivar failure_reason: Failure reason when blob restore is failed. + :vartype failure_reason: str + :ivar restore_id: Id for tracking blob restore request. + :vartype restore_id: str + :ivar parameters: Blob restore request parameters. + :vartype parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreParameters + """ + + _validation = { + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.status = None + self.failure_reason = None + self.restore_id = None + self.parameters = None + + +class BlobServiceItems(_serialization.Model): + """BlobServiceItems. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blob services returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BlobServiceProperties]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes + """The properties of a storage account’s Blob service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar sku: Sku name and tier. + :vartype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :ivar cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :vartype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + :ivar default_service_version: DefaultServiceVersion indicates the default version to use for + requests to the Blob service if an incoming request’s version is not specified. Possible values + include version 2008-10-27 and all more recent versions. + :vartype default_service_version: str + :ivar delete_retention_policy: The blob service properties for blob soft delete. + :vartype delete_retention_policy: ~azure.mgmt.storage.v2023_05_01.models.DeleteRetentionPolicy + :ivar is_versioning_enabled: Versioning is enabled if set to true. + :vartype is_versioning_enabled: bool + :ivar automatic_snapshot_policy_enabled: Deprecated in favor of isVersioningEnabled property. + :vartype automatic_snapshot_policy_enabled: bool + :ivar change_feed: The blob service properties for change feed events. + :vartype change_feed: ~azure.mgmt.storage.v2023_05_01.models.ChangeFeed + :ivar restore_policy: The blob service properties for blob restore policy. + :vartype restore_policy: ~azure.mgmt.storage.v2023_05_01.models.RestorePolicyProperties + :ivar container_delete_retention_policy: The blob service properties for container soft delete. + :vartype container_delete_retention_policy: + ~azure.mgmt.storage.v2023_05_01.models.DeleteRetentionPolicy + :ivar last_access_time_tracking_policy: The blob service property to configure last access time + based tracking policy. + :vartype last_access_time_tracking_policy: + ~azure.mgmt.storage.v2023_05_01.models.LastAccessTimeTrackingPolicy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + default_service_version: Optional[str] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + is_versioning_enabled: Optional[bool] = None, + automatic_snapshot_policy_enabled: Optional[bool] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :paramtype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + :keyword default_service_version: DefaultServiceVersion indicates the default version to use + for requests to the Blob service if an incoming request’s version is not specified. Possible + values include version 2008-10-27 and all more recent versions. + :paramtype default_service_version: str + :keyword delete_retention_policy: The blob service properties for blob soft delete. + :paramtype delete_retention_policy: + ~azure.mgmt.storage.v2023_05_01.models.DeleteRetentionPolicy + :keyword is_versioning_enabled: Versioning is enabled if set to true. + :paramtype is_versioning_enabled: bool + :keyword automatic_snapshot_policy_enabled: Deprecated in favor of isVersioningEnabled + property. + :paramtype automatic_snapshot_policy_enabled: bool + :keyword change_feed: The blob service properties for change feed events. + :paramtype change_feed: ~azure.mgmt.storage.v2023_05_01.models.ChangeFeed + :keyword restore_policy: The blob service properties for blob restore policy. + :paramtype restore_policy: ~azure.mgmt.storage.v2023_05_01.models.RestorePolicyProperties + :keyword container_delete_retention_policy: The blob service properties for container soft + delete. + :paramtype container_delete_retention_policy: + ~azure.mgmt.storage.v2023_05_01.models.DeleteRetentionPolicy + :keyword last_access_time_tracking_policy: The blob service property to configure last access + time based tracking policy. + :paramtype last_access_time_tracking_policy: + ~azure.mgmt.storage.v2023_05_01.models.LastAccessTimeTrackingPolicy + """ + super().__init__(**kwargs) + self.sku = None + self.cors = cors + self.default_service_version = default_service_version + self.delete_retention_policy = delete_retention_policy + self.is_versioning_enabled = is_versioning_enabled + self.automatic_snapshot_policy_enabled = automatic_snapshot_policy_enabled + self.change_feed = change_feed + self.restore_policy = restore_policy + self.container_delete_retention_policy = container_delete_retention_policy + self.last_access_time_tracking_policy = last_access_time_tracking_policy + + +class ChangeFeed(_serialization.Model): + """The blob service properties for change feed events. + + :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. + :vartype enabled: bool + :ivar retention_in_days: Indicates the duration of changeFeed retention in days. Minimum value + is 1 day and maximum value is 146000 days (400 years). A null value indicates an infinite + retention of the change feed. + :vartype retention_in_days: int + """ + + _validation = { + "retention_in_days": {"maximum": 146000, "minimum": 1}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, + } + + def __init__( + self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs: Any + ) -> None: + """ + :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. + :paramtype enabled: bool + :keyword retention_in_days: Indicates the duration of changeFeed retention in days. Minimum + value is 1 day and maximum value is 146000 days (400 years). A null value indicates an infinite + retention of the change feed. + :paramtype retention_in_days: int + """ + super().__init__(**kwargs) + self.enabled = enabled + self.retention_in_days = retention_in_days + + +class CheckNameAvailabilityResult(_serialization.Model): + """The CheckNameAvailability operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: Gets a boolean value that indicates whether the name is available for you + to use. If true, the name is available. If false, the name has already been taken or is invalid + and cannot be used. + :vartype name_available: bool + :ivar reason: Gets the reason that a storage account name could not be used. The Reason element + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.storage.v2023_05_01.models.Reason + :ivar message: Gets an error message explaining the Reason value in more detail. + :vartype message: str + """ + + _validation = { + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = None + + +class CloudErrorBody(_serialization.Model): + """An error response from the Storage service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.storage.v2023_05_01.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.storage.v2023_05_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class CorsRule(_serialization.Model): + """Specifies a CORS rule for the Blob service. + + All required parameters must be populated in order to send to server. + + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. + :vartype allowed_origins: list[str] + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. + :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2023_05_01.models.AllowedMethods] + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. + :vartype max_age_in_seconds: int + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. + :vartype exposed_headers: list[str] + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. + :vartype allowed_headers: list[str] + """ + + _validation = { + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, + } + + _attribute_map = { + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + } + + def __init__( + self, + *, + allowed_origins: List[str], + allowed_methods: List[Union[str, "_models.AllowedMethods"]], + max_age_in_seconds: int, + exposed_headers: List[str], + allowed_headers: List[str], + **kwargs: Any + ) -> None: + """ + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. + :paramtype allowed_origins: list[str] + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. + :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2023_05_01.models.AllowedMethods] + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. + :paramtype max_age_in_seconds: int + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. + :paramtype exposed_headers: list[str] + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. + :paramtype allowed_headers: list[str] + """ + super().__init__(**kwargs) + self.allowed_origins = allowed_origins + self.allowed_methods = allowed_methods + self.max_age_in_seconds = max_age_in_seconds + self.exposed_headers = exposed_headers + self.allowed_headers = allowed_headers + + +class CorsRules(_serialization.Model): + """Sets the CORS rules. You can include up to five CorsRule elements in the request. + + :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the + request. + :vartype cors_rules: list[~azure.mgmt.storage.v2023_05_01.models.CorsRule] + """ + + _attribute_map = { + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, + } + + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs: Any) -> None: + """ + :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in + the request. + :paramtype cors_rules: list[~azure.mgmt.storage.v2023_05_01.models.CorsRule] + """ + super().__init__(**kwargs) + self.cors_rules = cors_rules + + +class CustomDomain(_serialization.Model): + """The custom domain assigned to this storage account. This can be set via Update. + + All required parameters must be populated in order to send to server. + + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. + :vartype name: str + :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default + value is false. This should only be set on updates. + :vartype use_sub_domain_name: bool + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, + } + + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. + :paramtype name: str + :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default + value is false. This should only be set on updates. + :paramtype use_sub_domain_name: bool + """ + super().__init__(**kwargs) + self.name = name + self.use_sub_domain_name = use_sub_domain_name + + +class DateAfterCreation(_serialization.Model): + """Object to define snapshot and version action conditions. + + All required parameters must be populated in order to send to server. + + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. + :vartype days_after_creation_greater_than: float + :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob + will be archived if both the conditions are satisfied. + :vartype days_after_last_tier_change_greater_than: float + """ + + _validation = { + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, + } + + _attribute_map = { + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, + } + + def __init__( + self, + *, + days_after_creation_greater_than: float, + days_after_last_tier_change_greater_than: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. + :paramtype days_after_creation_greater_than: float + :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob + will be archived if both the conditions are satisfied. + :paramtype days_after_last_tier_change_greater_than: float + """ + super().__init__(**kwargs) + self.days_after_creation_greater_than = days_after_creation_greater_than + self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than + + +class DateAfterModification(_serialization.Model): + """Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, + daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The + daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which + requires daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with + daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan. + + :ivar days_after_modification_greater_than: Value indicating the age in days after last + modification. + :vartype days_after_modification_greater_than: float + :ivar days_after_last_access_time_greater_than: Value indicating the age in days after last + blob access. This property can only be used in conjunction with last access time tracking + policy. + :vartype days_after_last_access_time_greater_than: float + :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be + archived if both the conditions are satisfied. + :vartype days_after_last_tier_change_greater_than: float + :ivar days_after_creation_greater_than: Value indicating the age in days after blob creation. + :vartype days_after_creation_greater_than: float + """ + + _validation = { + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_creation_greater_than": {"minimum": 0, "multiple": 1}, + } + + _attribute_map = { + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, + } + + def __init__( + self, + *, + days_after_modification_greater_than: Optional[float] = None, + days_after_last_access_time_greater_than: Optional[float] = None, + days_after_last_tier_change_greater_than: Optional[float] = None, + days_after_creation_greater_than: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword days_after_modification_greater_than: Value indicating the age in days after last + modification. + :paramtype days_after_modification_greater_than: float + :keyword days_after_last_access_time_greater_than: Value indicating the age in days after last + blob access. This property can only be used in conjunction with last access time tracking + policy. + :paramtype days_after_last_access_time_greater_than: float + :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be + archived if both the conditions are satisfied. + :paramtype days_after_last_tier_change_greater_than: float + :keyword days_after_creation_greater_than: Value indicating the age in days after blob + creation. + :paramtype days_after_creation_greater_than: float + """ + super().__init__(**kwargs) + self.days_after_modification_greater_than = days_after_modification_greater_than + self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than + self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than + self.days_after_creation_greater_than = days_after_creation_greater_than + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + +class DeletedAccount(ProxyResource): + """Deleted storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar storage_account_resource_id: Full resource id of the original storage account. + :vartype storage_account_resource_id: str + :ivar location: Location of the deleted account. + :vartype location: str + :ivar restore_reference: Can be used to attempt recovering this deleted account via + PutStorageAccount API. + :vartype restore_reference: str + :ivar creation_time: Creation time of the deleted account. + :vartype creation_time: str + :ivar deletion_time: Deletion time of the deleted account. + :vartype deletion_time: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.storage_account_resource_id = None + self.location = None + self.restore_reference = None + self.creation_time = None + self.deletion_time = None + + +class DeletedAccountListResult(_serialization.Model): + """The response from the List Deleted Accounts operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of deleted accounts and their properties. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.DeletedAccount] + :ivar next_link: Request URL that can be used to query next page of deleted accounts. Returned + when total number of requested deleted accounts exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class DeletedShare(_serialization.Model): + """The deleted share to be restored. + + All required parameters must be populated in order to send to server. + + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. + :vartype deleted_share_name: str + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. + :vartype deleted_share_version: str + """ + + _validation = { + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, + } + + _attribute_map = { + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, + } + + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs: Any) -> None: + """ + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. + :paramtype deleted_share_name: str + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. + :paramtype deleted_share_version: str + """ + super().__init__(**kwargs) + self.deleted_share_name = deleted_share_name + self.deleted_share_version = deleted_share_version + + +class DeleteRetentionPolicy(_serialization.Model): + """The service properties for soft delete. + + :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. + :vartype enabled: bool + :ivar days: Indicates the number of days that the deleted item should be retained. The minimum + specified value can be 1 and the maximum value can be 365. + :vartype days: int + :ivar allow_permanent_delete: This property when set to true allows deletion of the soft + deleted blob versions and snapshots. This property cannot be used blob restore policy. This + property only applies to blob service and does not apply to containers or file share. + :vartype allow_permanent_delete: bool + """ + + _validation = { + "days": {"maximum": 365, "minimum": 1}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "allow_permanent_delete": {"key": "allowPermanentDelete", "type": "bool"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + days: Optional[int] = None, + allow_permanent_delete: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. + :paramtype enabled: bool + :keyword days: Indicates the number of days that the deleted item should be retained. The + minimum specified value can be 1 and the maximum value can be 365. + :paramtype days: int + :keyword allow_permanent_delete: This property when set to true allows deletion of the soft + deleted blob versions and snapshots. This property cannot be used blob restore policy. This + property only applies to blob service and does not apply to containers or file share. + :paramtype allow_permanent_delete: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + self.days = days + self.allow_permanent_delete = allow_permanent_delete + + +class Dimension(_serialization.Model): + """Dimension of blobs, possibly be blob type or access tier. + + :ivar name: Display name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Display name of dimension. + :paramtype name: str + :keyword display_name: Display name of dimension. + :paramtype display_name: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + + +class Encryption(_serialization.Model): + """The encryption settings on the storage account. + + :ivar services: List of services which support encryption. + :vartype services: ~azure.mgmt.storage.v2023_05_01.models.EncryptionServices + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". + :vartype key_source: str or ~azure.mgmt.storage.v2023_05_01.models.KeySource + :ivar require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :vartype require_infrastructure_encryption: bool + :ivar key_vault_properties: Properties provided by key vault. + :vartype key_vault_properties: ~azure.mgmt.storage.v2023_05_01.models.KeyVaultProperties + :ivar encryption_identity: The identity to be used with service-side encryption at rest. + :vartype encryption_identity: ~azure.mgmt.storage.v2023_05_01.models.EncryptionIdentity + """ + + _attribute_map = { + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, + } + + def __init__( + self, + *, + services: Optional["_models.EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + require_infrastructure_encryption: Optional[bool] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword services: List of services which support encryption. + :paramtype services: ~azure.mgmt.storage.v2023_05_01.models.EncryptionServices + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". + :paramtype key_source: str or ~azure.mgmt.storage.v2023_05_01.models.KeySource + :keyword require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :paramtype require_infrastructure_encryption: bool + :keyword key_vault_properties: Properties provided by key vault. + :paramtype key_vault_properties: ~azure.mgmt.storage.v2023_05_01.models.KeyVaultProperties + :keyword encryption_identity: The identity to be used with service-side encryption at rest. + :paramtype encryption_identity: ~azure.mgmt.storage.v2023_05_01.models.EncryptionIdentity + """ + super().__init__(**kwargs) + self.services = services + self.key_source = key_source + self.require_infrastructure_encryption = require_infrastructure_encryption + self.key_vault_properties = key_vault_properties + self.encryption_identity = encryption_identity + + +class EncryptionIdentity(_serialization.Model): + """Encryption identity for the storage account. + + :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be + associated with server-side encryption on the storage account. + :vartype encryption_user_assigned_identity: str + :ivar encryption_federated_identity_client_id: ClientId of the multi-tenant application to be + used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys + server-side encryption on the storage account. + :vartype encryption_federated_identity_client_id: str + """ + + _attribute_map = { + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "encryption_federated_identity_client_id": {"key": "federatedIdentityClientId", "type": "str"}, + } + + def __init__( + self, + *, + encryption_user_assigned_identity: Optional[str] = None, + encryption_federated_identity_client_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to + be associated with server-side encryption on the storage account. + :paramtype encryption_user_assigned_identity: str + :keyword encryption_federated_identity_client_id: ClientId of the multi-tenant application to + be used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys + server-side encryption on the storage account. + :paramtype encryption_federated_identity_client_id: str + """ + super().__init__(**kwargs) + self.encryption_user_assigned_identity = encryption_user_assigned_identity + self.encryption_federated_identity_client_id = encryption_federated_identity_client_id + + +class EncryptionScope(Resource): + """The Encryption Scope resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar source: The provider for the encryption scope. Possible values (case-insensitive): + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and + "Microsoft.KeyVault". + :vartype source: str or ~azure.mgmt.storage.v2023_05_01.models.EncryptionScopeSource + :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, + Disabled. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.storage.v2023_05_01.models.EncryptionScopeState + :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets the last modification date and time of the encryption scope in + UTC. + :vartype last_modified_time: ~datetime.datetime + :ivar key_vault_properties: The key vault properties for the encryption scope. This is a + required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + :vartype key_vault_properties: + ~azure.mgmt.storage.v2023_05_01.models.EncryptionScopeKeyVaultProperties + :ivar require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :vartype require_infrastructure_encryption: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, + } + + def __init__( + self, + *, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, + require_infrastructure_encryption: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword source: The provider for the encryption scope. Possible values (case-insensitive): + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and + "Microsoft.KeyVault". + :paramtype source: str or ~azure.mgmt.storage.v2023_05_01.models.EncryptionScopeSource + :keyword state: The state of the encryption scope. Possible values (case-insensitive): + Enabled, Disabled. Known values are: "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.storage.v2023_05_01.models.EncryptionScopeState + :keyword key_vault_properties: The key vault properties for the encryption scope. This is a + required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + :paramtype key_vault_properties: + ~azure.mgmt.storage.v2023_05_01.models.EncryptionScopeKeyVaultProperties + :keyword require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :paramtype require_infrastructure_encryption: bool + """ + super().__init__(**kwargs) + self.source = source + self.state = state + self.creation_time = None + self.last_modified_time = None + self.key_vault_properties = key_vault_properties + self.require_infrastructure_encryption = require_infrastructure_encryption + + +class EncryptionScopeKeyVaultProperties(_serialization.Model): + """The key vault properties for the encryption scope. This is a required field if encryption scope + 'source' attribute is set to 'Microsoft.KeyVault'. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_uri: The object identifier for a key vault key object. When applied, the encryption + scope will use the key referenced by the identifier to enable customer-managed key support on + this encryption scope. + :vartype key_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + """ + + _validation = { + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + } + + _attribute_map = { + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + } + + def __init__(self, *, key_uri: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword key_uri: The object identifier for a key vault key object. When applied, the + encryption scope will use the key referenced by the identifier to enable customer-managed key + support on this encryption scope. + :paramtype key_uri: str + """ + super().__init__(**kwargs) + self.key_uri = key_uri + self.current_versioned_key_identifier = None + self.last_key_rotation_timestamp = None + + +class EncryptionScopeListResult(_serialization.Model): + """List of encryption scopes requested, and if paging is required, a URL to the next page of + encryption scopes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of encryption scopes requested. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.EncryptionScope] + :ivar next_link: Request URL that can be used to query next page of encryption scopes. Returned + when total number of requested encryption scopes exceeds the maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class EncryptionService(_serialization.Model): + """A service that allows server-side encryption to be used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enabled: A boolean indicating whether or not the service encrypts the data as it is + stored. Encryption at rest is enabled by default today and cannot be disabled. + :vartype enabled: bool + :ivar last_enabled_time: Gets a rough estimate of the date/time when the encryption was last + enabled by the user. Data is encrypted at rest by default today and cannot be disabled. + :vartype last_enabled_time: ~datetime.datetime + :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type + implies that an account-scoped encryption key will be used. 'Service' key type implies that a + default service key is used. Known values are: "Service" and "Account". + :vartype key_type: str or ~azure.mgmt.storage.v2023_05_01.models.KeyType + """ + + _validation = { + "last_enabled_time": {"readonly": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, + } + + def __init__( + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs: Any + ) -> None: + """ + :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is + stored. Encryption at rest is enabled by default today and cannot be disabled. + :paramtype enabled: bool + :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key + type implies that an account-scoped encryption key will be used. 'Service' key type implies + that a default service key is used. Known values are: "Service" and "Account". + :paramtype key_type: str or ~azure.mgmt.storage.v2023_05_01.models.KeyType + """ + super().__init__(**kwargs) + self.enabled = enabled + self.last_enabled_time = None + self.key_type = key_type + + +class EncryptionServices(_serialization.Model): + """A list of services that support encryption. + + :ivar blob: The encryption function of the blob storage service. + :vartype blob: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + :ivar file: The encryption function of the file storage service. + :vartype file: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + :ivar table: The encryption function of the table storage service. + :vartype table: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + :ivar queue: The encryption function of the queue storage service. + :vartype queue: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + """ + + _attribute_map = { + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, + } + + def __init__( + self, + *, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, + **kwargs: Any + ) -> None: + """ + :keyword blob: The encryption function of the blob storage service. + :paramtype blob: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + :keyword file: The encryption function of the file storage service. + :paramtype file: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + :keyword table: The encryption function of the table storage service. + :paramtype table: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + :keyword queue: The encryption function of the queue storage service. + :paramtype queue: ~azure.mgmt.storage.v2023_05_01.models.EncryptionService + """ + super().__init__(**kwargs) + self.blob = blob + self.file = file + self.table = table + self.queue = queue + + +class Endpoints(_serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs + object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar queue: Gets the queue endpoint. + :vartype queue: str + :ivar table: Gets the table endpoint. + :vartype table: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + :ivar microsoft_endpoints: Gets the microsoft routing storage endpoints. + :vartype microsoft_endpoints: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMicrosoftEndpoints + :ivar internet_endpoints: Gets the internet routing storage endpoints. + :vartype internet_endpoints: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountInternetEndpoints + """ + + _validation = { + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, + } + + _attribute_map = { + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, + } + + def __init__( + self, + *, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, + **kwargs: Any + ) -> None: + """ + :keyword microsoft_endpoints: Gets the microsoft routing storage endpoints. + :paramtype microsoft_endpoints: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMicrosoftEndpoints + :keyword internet_endpoints: Gets the internet routing storage endpoints. + :paramtype internet_endpoints: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountInternetEndpoints + """ + super().__init__(**kwargs) + self.blob = None + self.queue = None + self.table = None + self.file = None + self.web = None + self.dfs = None + self.microsoft_endpoints = microsoft_endpoints + self.internet_endpoints = internet_endpoints + + +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.storage.v2023_05_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.storage.v2023_05_01.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): + """An error response from the storage resource provider. + + :ivar error: Azure Storage Resource Provider error response body. + :vartype error: ~azure.mgmt.storage.v2023_05_01.models.ErrorResponseBody + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseBody"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs: Any) -> None: + """ + :keyword error: Azure Storage Resource Provider error response body. + :paramtype error: ~azure.mgmt.storage.v2023_05_01.models.ErrorResponseBody + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAutoGenerated(_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.storage.v2023_05_01.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.storage.v2023_05_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseBody(_serialization.Model): + """Error response body contract. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ExecutionTarget(_serialization.Model): + """Target helps provide filter parameters for the objects in the storage account and forms the + execution context for the storage task. + + :ivar prefix: Required list of object prefixes to be included for task execution. + :vartype prefix: list[str] + :ivar exclude_prefix: List of object prefixes to be excluded from task execution. If there is a + conflict between include and exclude prefixes, the exclude prefix will be the determining + factor. + :vartype exclude_prefix: list[str] + """ + + _attribute_map = { + "prefix": {"key": "prefix", "type": "[str]"}, + "exclude_prefix": {"key": "excludePrefix", "type": "[str]"}, + } + + def __init__( + self, *, prefix: Optional[List[str]] = None, exclude_prefix: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword prefix: Required list of object prefixes to be included for task execution. + :paramtype prefix: list[str] + :keyword exclude_prefix: List of object prefixes to be excluded from task execution. If there + is a conflict between include and exclude prefixes, the exclude prefix will be the determining + factor. + :paramtype exclude_prefix: list[str] + """ + super().__init__(**kwargs) + self.prefix = prefix + self.exclude_prefix = exclude_prefix + + +class ExecutionTrigger(_serialization.Model): + """Execution trigger for storage task assignment. + + All required parameters must be populated in order to send to server. + + :ivar type: The trigger type of the storage task assignment execution. Required. Known values + are: "RunOnce" and "OnSchedule". + :vartype type: str or ~azure.mgmt.storage.v2023_05_01.models.TriggerType + :ivar parameters: The trigger parameters of the storage task assignment execution. Required. + :vartype parameters: ~azure.mgmt.storage.v2023_05_01.models.TriggerParameters + """ + + _validation = { + "type": {"required": True}, + "parameters": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "parameters": {"key": "parameters", "type": "TriggerParameters"}, + } + + def __init__( + self, *, type: Union[str, "_models.TriggerType"], parameters: "_models.TriggerParameters", **kwargs: Any + ) -> None: + """ + :keyword type: The trigger type of the storage task assignment execution. Required. Known + values are: "RunOnce" and "OnSchedule". + :paramtype type: str or ~azure.mgmt.storage.v2023_05_01.models.TriggerType + :keyword parameters: The trigger parameters of the storage task assignment execution. Required. + :paramtype parameters: ~azure.mgmt.storage.v2023_05_01.models.TriggerParameters + """ + super().__init__(**kwargs) + self.type = type + self.parameters = parameters + + +class ExecutionTriggerUpdate(_serialization.Model): + """Execution trigger update for storage task assignment. + + :ivar type: The trigger type of the storage task assignment execution. Known values are: + "RunOnce" and "OnSchedule". + :vartype type: str or ~azure.mgmt.storage.v2023_05_01.models.TriggerType + :ivar parameters: The trigger parameters of the storage task assignment execution. + :vartype parameters: ~azure.mgmt.storage.v2023_05_01.models.TriggerParametersUpdate + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "parameters": {"key": "parameters", "type": "TriggerParametersUpdate"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.TriggerType"]] = None, + parameters: Optional["_models.TriggerParametersUpdate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The trigger type of the storage task assignment execution. Known values are: + "RunOnce" and "OnSchedule". + :paramtype type: str or ~azure.mgmt.storage.v2023_05_01.models.TriggerType + :keyword parameters: The trigger parameters of the storage task assignment execution. + :paramtype parameters: ~azure.mgmt.storage.v2023_05_01.models.TriggerParametersUpdate + """ + super().__init__(**kwargs) + self.type = type + self.parameters = parameters + + +class ExtendedLocation(_serialization.Model): + """The complex type of the extended location. + + :ivar name: The name of the extended location. + :vartype name: str + :ivar type: The type of the extended location. "EdgeZone" + :vartype type: str or ~azure.mgmt.storage.v2023_05_01.models.ExtendedLocationTypes + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the extended location. + :paramtype name: str + :keyword type: The type of the extended location. "EdgeZone" + :paramtype type: str or ~azure.mgmt.storage.v2023_05_01.models.ExtendedLocationTypes + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class FileServiceItems(_serialization.Model): + """FileServiceItems. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of file services returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FileServiceProperties]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class FileServiceProperties(Resource): + """The properties of File services in storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar sku: Sku name and tier. + :vartype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :ivar cors: Specifies CORS rules for the File service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the File service. + :vartype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + :ivar share_delete_retention_policy: The file service properties for share soft delete. + :vartype share_delete_retention_policy: + ~azure.mgmt.storage.v2023_05_01.models.DeleteRetentionPolicy + :ivar protocol_settings: Protocol settings for file service. + :vartype protocol_settings: ~azure.mgmt.storage.v2023_05_01.models.ProtocolSettings + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword cors: Specifies CORS rules for the File service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the File service. + :paramtype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + :keyword share_delete_retention_policy: The file service properties for share soft delete. + :paramtype share_delete_retention_policy: + ~azure.mgmt.storage.v2023_05_01.models.DeleteRetentionPolicy + :keyword protocol_settings: Protocol settings for file service. + :paramtype protocol_settings: ~azure.mgmt.storage.v2023_05_01.models.ProtocolSettings + """ + super().__init__(**kwargs) + self.sku = None + self.cors = cors + self.share_delete_retention_policy = share_delete_retention_policy + self.protocol_settings = protocol_settings + + +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """Properties of the file share, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar last_modified_time: Returns the date and time the share was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar metadata: A name-value pair to associate with the share as metadata. + :vartype metadata: dict[str, str] + :ivar share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :vartype share_quota: int + :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only + be specified when creating a share. Known values are: "SMB" and "NFS". + :vartype enabled_protocols: str or ~azure.mgmt.storage.v2023_05_01.models.EnabledProtocols + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :vartype root_squash: str or ~azure.mgmt.storage.v2023_05_01.models.RootSquashType + :ivar version: The version of the share. + :vartype version: str + :ivar deleted: Indicates whether the share was deleted. + :vartype deleted: bool + :ivar deleted_time: The deleted time if the share was deleted. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. + :vartype remaining_retention_days: int + :ivar access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.ShareAccessTier + :ivar access_tier_change_time: Indicates the last modification time for share access tier. + :vartype access_tier_change_time: ~datetime.datetime + :ivar access_tier_status: Indicates if there is a pending transition for access tier. + :vartype access_tier_status: str + :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this + value may not include all recently created or recently resized files. + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, + only when the share is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseDuration + :ivar signed_identifiers: List of stored access policies specified on the share. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2023_05_01.models.SignedIdentifier] + :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares + with expand param "snapshots". + :vartype snapshot_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + share_quota: Optional[int] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword metadata: A name-value pair to associate with the share as metadata. + :paramtype metadata: dict[str, str] + :keyword share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :paramtype share_quota: int + :keyword enabled_protocols: The authentication protocol that is used for the file share. Can + only be specified when creating a share. Known values are: "SMB" and "NFS". + :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2023_05_01.models.EnabledProtocols + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :paramtype root_squash: str or ~azure.mgmt.storage.v2023_05_01.models.RootSquashType + :keyword access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.ShareAccessTier + :keyword signed_identifiers: List of stored access policies specified on the share. + :paramtype signed_identifiers: list[~azure.mgmt.storage.v2023_05_01.models.SignedIdentifier] + """ + super().__init__(**kwargs) + self.last_modified_time = None + self.metadata = metadata + self.share_quota = share_quota + self.enabled_protocols = enabled_protocols + self.root_squash = root_squash + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.access_tier = access_tier + self.access_tier_change_time = None + self.access_tier_status = None + self.share_usage_bytes = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.signed_identifiers = signed_identifiers + self.snapshot_time = None + + +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """The file share properties be listed out. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar last_modified_time: Returns the date and time the share was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar metadata: A name-value pair to associate with the share as metadata. + :vartype metadata: dict[str, str] + :ivar share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :vartype share_quota: int + :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only + be specified when creating a share. Known values are: "SMB" and "NFS". + :vartype enabled_protocols: str or ~azure.mgmt.storage.v2023_05_01.models.EnabledProtocols + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :vartype root_squash: str or ~azure.mgmt.storage.v2023_05_01.models.RootSquashType + :ivar version: The version of the share. + :vartype version: str + :ivar deleted: Indicates whether the share was deleted. + :vartype deleted: bool + :ivar deleted_time: The deleted time if the share was deleted. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. + :vartype remaining_retention_days: int + :ivar access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.ShareAccessTier + :ivar access_tier_change_time: Indicates the last modification time for share access tier. + :vartype access_tier_change_time: ~datetime.datetime + :ivar access_tier_status: Indicates if there is a pending transition for access tier. + :vartype access_tier_status: str + :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this + value may not include all recently created or recently resized files. + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, + only when the share is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseDuration + :ivar signed_identifiers: List of stored access policies specified on the share. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2023_05_01.models.SignedIdentifier] + :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares + with expand param "snapshots". + :vartype snapshot_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + share_quota: Optional[int] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword metadata: A name-value pair to associate with the share as metadata. + :paramtype metadata: dict[str, str] + :keyword share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :paramtype share_quota: int + :keyword enabled_protocols: The authentication protocol that is used for the file share. Can + only be specified when creating a share. Known values are: "SMB" and "NFS". + :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2023_05_01.models.EnabledProtocols + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :paramtype root_squash: str or ~azure.mgmt.storage.v2023_05_01.models.RootSquashType + :keyword access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.ShareAccessTier + :keyword signed_identifiers: List of stored access policies specified on the share. + :paramtype signed_identifiers: list[~azure.mgmt.storage.v2023_05_01.models.SignedIdentifier] + """ + super().__init__(**kwargs) + self.last_modified_time = None + self.metadata = metadata + self.share_quota = share_quota + self.enabled_protocols = enabled_protocols + self.root_squash = root_squash + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.access_tier = access_tier + self.access_tier_change_time = None + self.access_tier_status = None + self.share_usage_bytes = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.signed_identifiers = signed_identifiers + self.snapshot_time = None + + +class FileShareItems(_serialization.Model): + """Response schema. Contains list of shares returned, and if paging is requested or required, a + URL to next page of shares. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of file shares returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.FileShareItem] + :ivar next_link: Request URL that can be used to query next page of shares. Returned when total + number of requested shares exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class GeoReplicationStats(_serialization.Model): + """Statistics related to replication for storage account's Blob, Table, Queue and File services. + It is only available when geo-redundant replication is enabled for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of the secondary location. Possible values are: - Live: Indicates that + the secondary location is active and operational. - Bootstrap: Indicates initial + synchronization from the primary location to the secondary location is in progress.This + typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". + :vartype status: str or ~azure.mgmt.storage.v2023_05_01.models.GeoReplicationStatus + :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to + be available for read operations. Primary writes following this point in time may or may not be + available for reads. Element may be default value if value of LastSyncTime is not available, + this can happen if secondary is offline or we are in bootstrap. + :vartype last_sync_time: ~datetime.datetime + :ivar can_failover: A boolean flag which indicates whether or not account failover is supported + for the account. + :vartype can_failover: bool + :ivar can_planned_failover: A boolean flag which indicates whether or not planned account + failover is supported for the account. + :vartype can_planned_failover: bool + :ivar post_failover_redundancy: The redundancy type of the account after an account failover is + performed. Known values are: "Standard_LRS" and "Standard_ZRS". + :vartype post_failover_redundancy: str or + ~azure.mgmt.storage.v2023_05_01.models.PostFailoverRedundancy + :ivar post_planned_failover_redundancy: The redundancy type of the account after a planned + account failover is performed. Known values are: "Standard_GRS", "Standard_GZRS", + "Standard_RAGRS", and "Standard_RAGZRS". + :vartype post_planned_failover_redundancy: str or + ~azure.mgmt.storage.v2023_05_01.models.PostPlannedFailoverRedundancy + """ + + _validation = { + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, + "can_planned_failover": {"readonly": True}, + "post_failover_redundancy": {"readonly": True}, + "post_planned_failover_redundancy": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, + "can_planned_failover": {"key": "canPlannedFailover", "type": "bool"}, + "post_failover_redundancy": {"key": "postFailoverRedundancy", "type": "str"}, + "post_planned_failover_redundancy": {"key": "postPlannedFailoverRedundancy", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.status = None + self.last_sync_time = None + self.can_failover = None + self.can_planned_failover = None + self.post_failover_redundancy = None + self.post_planned_failover_redundancy = None + + +class Identity(_serialization.Model): + """Identity for the 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 server. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.storage.v2023_05_01.models.IdentityType + :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of + User Assigned identities that will be used with this storage account. The key is the ARM + resource identifier of the identity. Only 1 User Assigned identity is permitted here. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.storage.v2023_05_01.models.UserAssignedIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.storage.v2023_05_01.models.IdentityType + :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set + of User Assigned identities that will be used with this storage account. The key is the ARM + resource identifier of the identity. Only 1 User Assigned identity is permitted here. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.storage.v2023_05_01.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ImmutabilityPolicy(AzureEntityResource): + """The ImmutabilityPolicy property of a blob container, including Id, resource name, resource + type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked + and Unlocked. Known values are: "Locked" and "Unlocked". + :vartype state: str or ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class ImmutabilityPolicyProperties(_serialization.Model): + """The properties of an ImmutabilityPolicy of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar etag: ImmutabilityPolicy Etag. + :vartype etag: str + :ivar update_history: The ImmutabilityPolicy update history of the blob container. + :vartype update_history: list[~azure.mgmt.storage.v2023_05_01.models.UpdateHistoryProperty] + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked + and Unlocked. Known values are: "Locked" and "Unlocked". + :vartype state: str or ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, + } + + _attribute_map = { + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.etag = None + self.update_history = None + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class ImmutableStorageAccount(_serialization.Model): + """This property enables and defines account-level immutability. Enabling the feature auto-enables + Blob Versioning. + + :ivar enabled: A boolean flag which enables account-level immutability. All the containers + under such an account have object-level immutability enabled by default. + :vartype enabled: bool + :ivar immutability_policy: Specifies the default account-level immutability policy which is + inherited and applied to objects that do not possess an explicit immutability policy at the + object level. The object-level immutability policy has higher precedence than the + container-level immutability policy, which has a higher precedence than the account-level + immutability policy. + :vartype immutability_policy: + ~azure.mgmt.storage.v2023_05_01.models.AccountImmutabilityPolicyProperties + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "immutability_policy": {"key": "immutabilityPolicy", "type": "AccountImmutabilityPolicyProperties"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + immutability_policy: Optional["_models.AccountImmutabilityPolicyProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: A boolean flag which enables account-level immutability. All the containers + under such an account have object-level immutability enabled by default. + :paramtype enabled: bool + :keyword immutability_policy: Specifies the default account-level immutability policy which is + inherited and applied to objects that do not possess an explicit immutability policy at the + object level. The object-level immutability policy has higher precedence than the + container-level immutability policy, which has a higher precedence than the account-level + immutability policy. + :paramtype immutability_policy: + ~azure.mgmt.storage.v2023_05_01.models.AccountImmutabilityPolicyProperties + """ + super().__init__(**kwargs) + self.enabled = enabled + self.immutability_policy = immutability_policy + + +class ImmutableStorageWithVersioning(_serialization.Model): + """Object level immutability properties of the container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enabled: This is an immutable property, when set to true it enables object level + immutability at the container level. + :vartype enabled: bool + :ivar time_stamp: Returns the date and time the object level immutability was enabled. + :vartype time_stamp: ~datetime.datetime + :ivar migration_state: This property denotes the container level immutability to object level + immutability migration state. Known values are: "InProgress" and "Completed". + :vartype migration_state: str or ~azure.mgmt.storage.v2023_05_01.models.MigrationState + """ + + _validation = { + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: This is an immutable property, when set to true it enables object level + immutability at the container level. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + self.time_stamp = None + self.migration_state = None + + +class IPRule(_serialization.Model): + """IP rule with specific IP or IP range in CIDR format. + + All required parameters must be populated in order to send to server. + + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :vartype ip_address_or_range: str + :ivar action: The action of IP ACL rule. Default value is "Allow". + :vartype action: str + """ + + _validation = { + "ip_address_or_range": {"required": True}, + } + + _attribute_map = { + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, + } + + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs: Any) -> None: + """ + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :paramtype ip_address_or_range: str + :keyword action: The action of IP ACL rule. Default value is "Allow". + :paramtype action: str + """ + super().__init__(**kwargs) + self.ip_address_or_range = ip_address_or_range + self.action = action + + +class KeyCreationTime(_serialization.Model): + """Storage account keys creation time. + + :ivar key1: + :vartype key1: ~datetime.datetime + :ivar key2: + :vartype key2: ~datetime.datetime + """ + + _attribute_map = { + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, + } + + def __init__( + self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs: Any + ) -> None: + """ + :keyword key1: + :paramtype key1: ~datetime.datetime + :keyword key2: + :paramtype key2: ~datetime.datetime + """ + super().__init__(**kwargs) + self.key1 = key1 + self.key2 = key2 + + +class KeyPolicy(_serialization.Model): + """KeyPolicy assigned to the storage account. + + All required parameters must be populated in order to send to server. + + :ivar key_expiration_period_in_days: The key expiration period in days. Required. + :vartype key_expiration_period_in_days: int + """ + + _validation = { + "key_expiration_period_in_days": {"required": True}, + } + + _attribute_map = { + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, + } + + def __init__(self, *, key_expiration_period_in_days: int, **kwargs: Any) -> None: + """ + :keyword key_expiration_period_in_days: The key expiration period in days. Required. + :paramtype key_expiration_period_in_days: int + """ + super().__init__(**kwargs) + self.key_expiration_period_in_days = key_expiration_period_in_days + + +class KeyVaultProperties(_serialization.Model): + """Properties of key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_name: The name of KeyVault key. + :vartype key_name: str + :ivar key_version: The version of KeyVault key. + :vartype key_version: str + :ivar key_vault_uri: The Uri of KeyVault. + :vartype key_vault_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + :ivar current_versioned_key_expiration_timestamp: This is a read only property that represents + the expiration time of the current version of the customer managed key used for encryption. + :vartype current_versioned_key_expiration_timestamp: ~datetime.datetime + """ + + _validation = { + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + "current_versioned_key_expiration_timestamp": {"readonly": True}, + } + + _attribute_map = { + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + "current_versioned_key_expiration_timestamp": { + "key": "currentVersionedKeyExpirationTimestamp", + "type": "iso-8601", + }, + } + + def __init__( + self, + *, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + key_vault_uri: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword key_name: The name of KeyVault key. + :paramtype key_name: str + :keyword key_version: The version of KeyVault key. + :paramtype key_version: str + :keyword key_vault_uri: The Uri of KeyVault. + :paramtype key_vault_uri: str + """ + super().__init__(**kwargs) + self.key_name = key_name + self.key_version = key_version + self.key_vault_uri = key_vault_uri + self.current_versioned_key_identifier = None + self.last_key_rotation_timestamp = None + self.current_versioned_key_expiration_timestamp = None + + +class LastAccessTimeTrackingPolicy(_serialization.Model): + """The blob service properties for Last access time based tracking policy. + + All required parameters must be populated in order to send to server. + + :ivar enable: When set to true last access time based tracking is enabled. Required. + :vartype enable: bool + :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently + read only. "AccessTimeTracking" + :vartype name: str or ~azure.mgmt.storage.v2023_05_01.models.Name + :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in + days, typically how often the blob object should be tracked.This field is currently read only + with value as 1. + :vartype tracking_granularity_in_days: int + :ivar blob_type: An array of predefined supported blob types. Only blockBlob is the supported + value. This field is currently read only. + :vartype blob_type: list[str] + """ + + _validation = { + "enable": {"required": True}, + } + + _attribute_map = { + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, + } + + def __init__( + self, + *, + enable: bool, + name: Optional[Union[str, "_models.Name"]] = None, + tracking_granularity_in_days: Optional[int] = None, + blob_type: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword enable: When set to true last access time based tracking is enabled. Required. + :paramtype enable: bool + :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is + currently read only. "AccessTimeTracking" + :paramtype name: str or ~azure.mgmt.storage.v2023_05_01.models.Name + :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in + days, typically how often the blob object should be tracked.This field is currently read only + with value as 1. + :paramtype tracking_granularity_in_days: int + :keyword blob_type: An array of predefined supported blob types. Only blockBlob is the + supported value. This field is currently read only. + :paramtype blob_type: list[str] + """ + super().__init__(**kwargs) + self.enable = enable + self.name = name + self.tracking_granularity_in_days = tracking_granularity_in_days + self.blob_type = blob_type + + +class LeaseContainerRequest(_serialization.Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to server. + + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". + :vartype action: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerRequestEnum + :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :vartype lease_id: str + :ivar break_period: Optional. For a break action, proposed duration the lease should continue + before it is broken, in seconds, between 0 and 60. + :vartype break_period: int + :ivar lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, or + negative one (-1) for a lease that never expires. + :vartype lease_duration: int + :ivar proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :vartype proposed_lease_id: str + """ + + _validation = { + "action": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, + } + + def __init__( + self, + *, + action: Union[str, "_models.LeaseContainerRequestEnum"], + lease_id: Optional[str] = None, + break_period: Optional[int] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". + :paramtype action: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerRequestEnum + :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :paramtype lease_id: str + :keyword break_period: Optional. For a break action, proposed duration the lease should + continue before it is broken, in seconds, between 0 and 60. + :paramtype break_period: int + :keyword lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, + or negative one (-1) for a lease that never expires. + :paramtype lease_duration: int + :keyword proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :paramtype proposed_lease_id: str + """ + super().__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id + + +class LeaseContainerResponse(_serialization.Model): + """Lease Container response schema. + + :ivar lease_id: Returned unique lease ID that must be included with any request to delete the + container, or to renew, change, or release the lease. + :vartype lease_id: str + :ivar lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :vartype lease_time_seconds: str + """ + + _attribute_map = { + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, + } + + def __init__( + self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword lease_id: Returned unique lease ID that must be included with any request to delete + the container, or to renew, change, or release the lease. + :paramtype lease_id: str + :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :paramtype lease_time_seconds: str + """ + super().__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds + + +class LeaseShareRequest(_serialization.Model): + """Lease Share request schema. + + All required parameters must be populated in order to send to server. + + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". + :vartype action: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseShareAction + :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :vartype lease_id: str + :ivar break_period: Optional. For a break action, proposed duration the lease should continue + before it is broken, in seconds, between 0 and 60. + :vartype break_period: int + :ivar lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, or + negative one (-1) for a lease that never expires. + :vartype lease_duration: int + :ivar proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :vartype proposed_lease_id: str + """ + + _validation = { + "action": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, + } + + def __init__( + self, + *, + action: Union[str, "_models.LeaseShareAction"], + lease_id: Optional[str] = None, + break_period: Optional[int] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". + :paramtype action: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseShareAction + :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :paramtype lease_id: str + :keyword break_period: Optional. For a break action, proposed duration the lease should + continue before it is broken, in seconds, between 0 and 60. + :paramtype break_period: int + :keyword lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, + or negative one (-1) for a lease that never expires. + :paramtype lease_duration: int + :keyword proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :paramtype proposed_lease_id: str + """ + super().__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id + + +class LeaseShareResponse(_serialization.Model): + """Lease Share response schema. + + :ivar lease_id: Returned unique lease ID that must be included with any request to delete the + share, or to renew, change, or release the lease. + :vartype lease_id: str + :ivar lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :vartype lease_time_seconds: str + """ + + _attribute_map = { + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, + } + + def __init__( + self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword lease_id: Returned unique lease ID that must be included with any request to delete + the share, or to renew, change, or release the lease. + :paramtype lease_id: str + :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :paramtype lease_time_seconds: str + """ + super().__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds + + +class LegalHold(_serialization.Model): + """The LegalHold property of a blob container. + + 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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. + :vartype tags: list[str] + :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, + } + + _attribute_map = { + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, *, tags: List[str], allow_protected_append_writes_all: Optional[bool] = None, **kwargs: Any + ) -> None: + """ + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. + :paramtype tags: list[str] + :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.has_legal_hold = None + self.tags = tags + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class LegalHoldProperties(_serialization.Model): + """The LegalHold property of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar tags: The list of LegalHold tags of a blob container. + :vartype tags: list[~azure.mgmt.storage.v2023_05_01.models.TagProperty] + :ivar protected_append_writes_history: Protected append blob writes history. + :vartype protected_append_writes_history: + ~azure.mgmt.storage.v2023_05_01.models.ProtectedAppendWritesHistory + """ + + _validation = { + "has_legal_hold": {"readonly": True}, + } + + _attribute_map = { + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, + "protected_append_writes_history": { + "key": "protectedAppendWritesHistory", + "type": "ProtectedAppendWritesHistory", + }, + } + + def __init__( + self, + *, + tags: Optional[List["_models.TagProperty"]] = None, + protected_append_writes_history: Optional["_models.ProtectedAppendWritesHistory"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: The list of LegalHold tags of a blob container. + :paramtype tags: list[~azure.mgmt.storage.v2023_05_01.models.TagProperty] + :keyword protected_append_writes_history: Protected append blob writes history. + :paramtype protected_append_writes_history: + ~azure.mgmt.storage.v2023_05_01.models.ProtectedAppendWritesHistory + """ + super().__init__(**kwargs) + self.has_legal_hold = None + self.tags = tags + self.protected_append_writes_history = protected_append_writes_history + + +class ListAccountSasResponse(_serialization.Model): + """The List SAS credentials operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_sas_token: List SAS credentials of storage account. + :vartype account_sas_token: str + """ + + _validation = { + "account_sas_token": {"readonly": True}, + } + + _attribute_map = { + "account_sas_token": {"key": "accountSasToken", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.account_sas_token = None + + +class ListBlobInventoryPolicy(_serialization.Model): + """List of blob inventory policies returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blob inventory policies. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """The blob container properties be listed out. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar version: The version of the deleted blob container. + :vartype version: str + :ivar deleted: Indicates whether the blob container was deleted. + :vartype deleted: bool + :ivar deleted_time: Blob container deletion time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for soft deleted blob container. + :vartype remaining_retention_days: int + :ivar default_encryption_scope: Default the container to use specified encryption scope for all + writes. + :vartype default_encryption_scope: str + :ivar deny_encryption_scope_override: Block override of encryption scope from the container + default. + :vartype deny_encryption_scope_override: bool + :ivar public_access: Specifies whether data in the container may be accessed publicly and the + level of access. Known values are: "Container", "Blob", and "None". + :vartype public_access: str or ~azure.mgmt.storage.v2023_05_01.models.PublicAccess + :ivar last_modified_time: Returns the date and time the container was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2023_05_01.models.LeaseDuration + :ivar metadata: A name-value pair to associate with the container as metadata. + :vartype metadata: dict[str, str] + :ivar immutability_policy: The ImmutabilityPolicy property of the container. + :vartype immutability_policy: + ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicyProperties + :ivar legal_hold: The LegalHold property of the container. + :vartype legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHoldProperties + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar has_immutability_policy: The hasImmutabilityPolicy public property is set to true by SRP + if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public + property is set to false by SRP if ImmutabilityPolicy has not been created for this container. + :vartype has_immutability_policy: bool + :ivar immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageWithVersioning + :ivar enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :vartype enable_nfs_v3_root_squash: bool + :ivar enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :vartype enable_nfs_v3_all_squash: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, + } + + def __init__( + self, + *, + default_encryption_scope: Optional[str] = None, + deny_encryption_scope_override: Optional[bool] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, + metadata: Optional[Dict[str, str]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, + enable_nfs_v3_root_squash: Optional[bool] = None, + enable_nfs_v3_all_squash: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword default_encryption_scope: Default the container to use specified encryption scope for + all writes. + :paramtype default_encryption_scope: str + :keyword deny_encryption_scope_override: Block override of encryption scope from the container + default. + :paramtype deny_encryption_scope_override: bool + :keyword public_access: Specifies whether data in the container may be accessed publicly and + the level of access. Known values are: "Container", "Blob", and "None". + :paramtype public_access: str or ~azure.mgmt.storage.v2023_05_01.models.PublicAccess + :keyword metadata: A name-value pair to associate with the container as metadata. + :paramtype metadata: dict[str, str] + :keyword immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageWithVersioning + :keyword enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :paramtype enable_nfs_v3_root_squash: bool + :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :paramtype enable_nfs_v3_all_squash: bool + """ + super().__init__(**kwargs) + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.default_encryption_scope = default_encryption_scope + self.deny_encryption_scope_override = deny_encryption_scope_override + self.public_access = public_access + self.last_modified_time = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.metadata = metadata + self.immutability_policy = None + self.legal_hold = None + self.has_legal_hold = None + self.has_immutability_policy = None + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.enable_nfs_v3_root_squash = enable_nfs_v3_root_squash + self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash + + +class ListContainerItems(_serialization.Model): + """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL + to next page of containers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blobs containers returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.ListContainerItem] + :ivar next_link: Request URL that can be used to query next page of containers. Returned when + total number of requested containers exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListQueue(Resource): + """ListQueue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar metadata: A name-value pair that represents queue metadata. + :vartype metadata: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + } + + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword metadata: A name-value pair that represents queue metadata. + :paramtype metadata: dict[str, str] + """ + super().__init__(**kwargs) + self.metadata = metadata + + +class ListQueueResource(_serialization.Model): + """Response schema. Contains list of queues returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of queues returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.ListQueue] + :ivar next_link: Request URL that can be used to list next page of queues. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListQueueServices(_serialization.Model): + """ListQueueServices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of queue services returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[QueueServiceProperties]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class ListServiceSasResponse(_serialization.Model): + """The List service SAS credentials operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar service_sas_token: List service SAS credentials of specific resource. + :vartype service_sas_token: str + """ + + _validation = { + "service_sas_token": {"readonly": True}, + } + + _attribute_map = { + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.service_sas_token = None + + +class ListTableResource(_serialization.Model): + """Response schema. Contains list of tables returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of tables returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.Table] + :ivar next_link: Request URL that can be used to query next page of tables. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListTableServices(_serialization.Model): + """ListTableServices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of table services returned. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[TableServiceProperties]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class LocalUser(Resource): # pylint: disable=too-many-instance-attributes + """The local user associated with the storage accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.storage.v2023_05_01.models.SystemData + :ivar permission_scopes: The permission scopes of the local user. + :vartype permission_scopes: list[~azure.mgmt.storage.v2023_05_01.models.PermissionScope] + :ivar home_directory: Optional, local user home directory. + :vartype home_directory: str + :ivar ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :vartype ssh_authorized_keys: list[~azure.mgmt.storage.v2023_05_01.models.SshPublicKey] + :ivar sid: A unique Security Identifier that is generated by the server. + :vartype sid: str + :ivar has_shared_key: Indicates whether shared key exists. Set it to false to remove existing + shared key. + :vartype has_shared_key: bool + :ivar has_ssh_key: Indicates whether ssh key exists. Set it to false to remove existing SSH + key. + :vartype has_ssh_key: bool + :ivar has_ssh_password: Indicates whether ssh password exists. Set it to false to remove + existing SSH password. + :vartype has_ssh_password: bool + :ivar user_id: A unique Identifier that is generated by the server. + :vartype user_id: int + :ivar group_id: An identifier for associating a group of users. + :vartype group_id: int + :ivar allow_acl_authorization: Indicates whether ACL authorization is allowed for this user. + Set it to false to disallow using ACL authorization. + :vartype allow_acl_authorization: bool + :ivar extended_groups: Supplementary group membership. Only applicable for local users enabled + for NFSv3 access. + :vartype extended_groups: list[int] + :ivar is_nf_sv3_enabled: Indicates if the local user is enabled for access with NFSv3 protocol. + :vartype is_nf_sv3_enabled: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "sid": {"readonly": True}, + "user_id": {"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"}, + "permission_scopes": {"key": "properties.permissionScopes", "type": "[PermissionScope]"}, + "home_directory": {"key": "properties.homeDirectory", "type": "str"}, + "ssh_authorized_keys": {"key": "properties.sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "sid": {"key": "properties.sid", "type": "str"}, + "has_shared_key": {"key": "properties.hasSharedKey", "type": "bool"}, + "has_ssh_key": {"key": "properties.hasSshKey", "type": "bool"}, + "has_ssh_password": {"key": "properties.hasSshPassword", "type": "bool"}, + "user_id": {"key": "properties.userId", "type": "int"}, + "group_id": {"key": "properties.groupId", "type": "int"}, + "allow_acl_authorization": {"key": "properties.allowAclAuthorization", "type": "bool"}, + "extended_groups": {"key": "properties.extendedGroups", "type": "[int]"}, + "is_nf_sv3_enabled": {"key": "properties.isNFSv3Enabled", "type": "bool"}, + } + + def __init__( + self, + *, + permission_scopes: Optional[List["_models.PermissionScope"]] = None, + home_directory: Optional[str] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, + has_shared_key: Optional[bool] = None, + has_ssh_key: Optional[bool] = None, + has_ssh_password: Optional[bool] = None, + group_id: Optional[int] = None, + allow_acl_authorization: Optional[bool] = None, + extended_groups: Optional[List[int]] = None, + is_nf_sv3_enabled: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword permission_scopes: The permission scopes of the local user. + :paramtype permission_scopes: list[~azure.mgmt.storage.v2023_05_01.models.PermissionScope] + :keyword home_directory: Optional, local user home directory. + :paramtype home_directory: str + :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2023_05_01.models.SshPublicKey] + :keyword has_shared_key: Indicates whether shared key exists. Set it to false to remove + existing shared key. + :paramtype has_shared_key: bool + :keyword has_ssh_key: Indicates whether ssh key exists. Set it to false to remove existing SSH + key. + :paramtype has_ssh_key: bool + :keyword has_ssh_password: Indicates whether ssh password exists. Set it to false to remove + existing SSH password. + :paramtype has_ssh_password: bool + :keyword group_id: An identifier for associating a group of users. + :paramtype group_id: int + :keyword allow_acl_authorization: Indicates whether ACL authorization is allowed for this user. + Set it to false to disallow using ACL authorization. + :paramtype allow_acl_authorization: bool + :keyword extended_groups: Supplementary group membership. Only applicable for local users + enabled for NFSv3 access. + :paramtype extended_groups: list[int] + :keyword is_nf_sv3_enabled: Indicates if the local user is enabled for access with NFSv3 + protocol. + :paramtype is_nf_sv3_enabled: bool + """ + super().__init__(**kwargs) + self.system_data = None + self.permission_scopes = permission_scopes + self.home_directory = home_directory + self.ssh_authorized_keys = ssh_authorized_keys + self.sid = None + self.has_shared_key = has_shared_key + self.has_ssh_key = has_ssh_key + self.has_ssh_password = has_ssh_password + self.user_id = None + self.group_id = group_id + self.allow_acl_authorization = allow_acl_authorization + self.extended_groups = extended_groups + self.is_nf_sv3_enabled = is_nf_sv3_enabled + + +class LocalUserKeys(_serialization.Model): + """The Storage Account Local User keys. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :vartype ssh_authorized_keys: list[~azure.mgmt.storage.v2023_05_01.models.SshPublicKey] + :ivar shared_key: Auto generated by the server for SMB authentication. + :vartype shared_key: str + """ + + _validation = { + "shared_key": {"readonly": True}, + } + + _attribute_map = { + "ssh_authorized_keys": {"key": "sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "shared_key": {"key": "sharedKey", "type": "str"}, + } + + def __init__(self, *, ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: + """ + :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2023_05_01.models.SshPublicKey] + """ + super().__init__(**kwargs) + self.ssh_authorized_keys = ssh_authorized_keys + self.shared_key = None + + +class LocalUserRegeneratePasswordResult(_serialization.Model): + """The secrets of Storage Account Local User. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ssh_password: Auto generated password by the server for SSH authentication if + hasSshPassword is set to true on the creation of local user. + :vartype ssh_password: str + """ + + _validation = { + "ssh_password": {"readonly": True}, + } + + _attribute_map = { + "ssh_password": {"key": "sshPassword", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.ssh_password = None + + +class LocalUsers(_serialization.Model): + """List of local users requested, and if paging is required, a URL to the next page of local + users. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of local users associated with the storage account. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.LocalUser] + :ivar next_link: Request URL that can be used to query next page of local users. Returned when + total number of requested local users exceeds the maximum page size. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[LocalUser]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.LocalUser"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of local users associated with the storage account. + :paramtype value: list[~azure.mgmt.storage.v2023_05_01.models.LocalUser] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ManagementPolicy(Resource): + """The Get Storage Account ManagementPolicies operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar policy: The Storage Account ManagementPolicy, in JSON format. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :vartype policy: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicySchema + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, + } + + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs: Any) -> None: + """ + :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :paramtype policy: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicySchema + """ + super().__init__(**kwargs) + self.last_modified_time = None + self.policy = policy + + +class ManagementPolicyAction(_serialization.Model): + """Actions are applied to the filtered blobs when the execution condition is met. + + :ivar base_blob: The management policy action for base blob. + :vartype base_blob: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyBaseBlob + :ivar snapshot: The management policy action for snapshot. + :vartype snapshot: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicySnapShot + :ivar version: The management policy action for version. + :vartype version: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyVersion + """ + + _attribute_map = { + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, + } + + def __init__( + self, + *, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, + **kwargs: Any + ) -> None: + """ + :keyword base_blob: The management policy action for base blob. + :paramtype base_blob: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyBaseBlob + :keyword snapshot: The management policy action for snapshot. + :paramtype snapshot: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicySnapShot + :keyword version: The management policy action for version. + :paramtype version: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyVersion + """ + super().__init__(**kwargs) + self.base_blob = base_blob + self.snapshot = snapshot + self.version = version + + +class ManagementPolicyBaseBlob(_serialization.Model): + """Management policy action for base blob. + + :ivar tier_to_cool: The function to tier blobs to cool storage. + :vartype tier_to_cool: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :ivar tier_to_archive: The function to tier blobs to archive storage. + :vartype tier_to_archive: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :ivar tier_to_cold: The function to tier blobs to cold storage. + :vartype tier_to_cold: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :ivar tier_to_hot: The function to tier blobs to hot storage. This action can only be used with + Premium Block Blob Storage Accounts. + :vartype tier_to_hot: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :ivar delete: The function to delete the blob. + :vartype delete: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :ivar enable_auto_tier_to_hot_from_cool: This property enables auto tiering of a blob from cool + to hot on a blob access. This property requires tierToCool.daysAfterLastAccessTimeGreaterThan. + :vartype enable_auto_tier_to_hot_from_cool: bool + """ + + _attribute_map = { + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "tier_to_cold": {"key": "tierToCold", "type": "DateAfterModification"}, + "tier_to_hot": {"key": "tierToHot", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + tier_to_cold: Optional["_models.DateAfterModification"] = None, + tier_to_hot: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, + enable_auto_tier_to_hot_from_cool: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword tier_to_cool: The function to tier blobs to cool storage. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :keyword tier_to_archive: The function to tier blobs to archive storage. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :keyword tier_to_cold: The function to tier blobs to cold storage. + :paramtype tier_to_cold: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :keyword tier_to_hot: The function to tier blobs to hot storage. This action can only be used + with Premium Block Blob Storage Accounts. + :paramtype tier_to_hot: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :keyword delete: The function to delete the blob. + :paramtype delete: ~azure.mgmt.storage.v2023_05_01.models.DateAfterModification + :keyword enable_auto_tier_to_hot_from_cool: This property enables auto tiering of a blob from + cool to hot on a blob access. This property requires + tierToCool.daysAfterLastAccessTimeGreaterThan. + :paramtype enable_auto_tier_to_hot_from_cool: bool + """ + super().__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.tier_to_cold = tier_to_cold + self.tier_to_hot = tier_to_hot + self.delete = delete + self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool + + +class ManagementPolicyDefinition(_serialization.Model): + """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an + actions set. + + All required parameters must be populated in order to send to server. + + :ivar actions: An object that defines the action set. Required. + :vartype actions: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyAction + :ivar filters: An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyFilter + """ + + _validation = { + "actions": {"required": True}, + } + + _attribute_map = { + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, + } + + def __init__( + self, + *, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, + **kwargs: Any + ) -> None: + """ + :keyword actions: An object that defines the action set. Required. + :paramtype actions: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyAction + :keyword filters: An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyFilter + """ + super().__init__(**kwargs) + self.actions = actions + self.filters = filters + + +class ManagementPolicyFilter(_serialization.Model): + """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters + are defined, a logical AND is performed on all filters. + + All required parameters must be populated in order to send to server. + + :ivar prefix_match: An array of strings for prefixes to be match. + :vartype prefix_match: list[str] + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. + :vartype blob_types: list[str] + :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag + filters. + :vartype blob_index_match: list[~azure.mgmt.storage.v2023_05_01.models.TagFilter] + """ + + _validation = { + "blob_types": {"required": True}, + } + + _attribute_map = { + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, + } + + def __init__( + self, + *, + blob_types: List[str], + prefix_match: Optional[List[str]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword prefix_match: An array of strings for prefixes to be match. + :paramtype prefix_match: list[str] + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. + :paramtype blob_types: list[str] + :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 + tag filters. + :paramtype blob_index_match: list[~azure.mgmt.storage.v2023_05_01.models.TagFilter] + """ + super().__init__(**kwargs) + self.prefix_match = prefix_match + self.blob_types = blob_types + self.blob_index_match = blob_index_match + + +class ManagementPolicyRule(_serialization.Model): + """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. + + All required parameters must be populated in order to send to server. + + :ivar enabled: Rule is enabled if set to true. + :vartype enabled: bool + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. + :vartype name: str + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" + :vartype type: str or ~azure.mgmt.storage.v2023_05_01.models.RuleType + :ivar definition: An object that defines the Lifecycle rule. Required. + :vartype definition: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyDefinition + """ + + _validation = { + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, + } + + def __init__( + self, + *, + name: str, + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", + enabled: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Rule is enabled if set to true. + :paramtype enabled: bool + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. + :paramtype name: str + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" + :paramtype type: str or ~azure.mgmt.storage.v2023_05_01.models.RuleType + :keyword definition: An object that defines the Lifecycle rule. Required. + :paramtype definition: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyDefinition + """ + super().__init__(**kwargs) + self.enabled = enabled + self.name = name + self.type = type + self.definition = definition + + +class ManagementPolicySchema(_serialization.Model): + """The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + + All required parameters must be populated in order to send to server. + + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. + :vartype rules: list[~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyRule] + """ + + _validation = { + "rules": {"required": True}, + } + + _attribute_map = { + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, + } + + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs: Any) -> None: + """ + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. + :paramtype rules: list[~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyRule] + """ + super().__init__(**kwargs) + self.rules = rules + + +class ManagementPolicySnapShot(_serialization.Model): + """Management policy action for snapshot. + + :ivar tier_to_cool: The function to tier blob snapshot to cool storage. + :vartype tier_to_cool: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar tier_to_archive: The function to tier blob snapshot to archive storage. + :vartype tier_to_archive: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar tier_to_cold: The function to tier blobs to cold storage. + :vartype tier_to_cold: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar tier_to_hot: The function to tier blobs to hot storage. This action can only be used with + Premium Block Blob Storage Accounts. + :vartype tier_to_hot: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar delete: The function to delete the blob snapshot. + :vartype delete: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + """ + + _attribute_map = { + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "tier_to_cold": {"key": "tierToCold", "type": "DateAfterCreation"}, + "tier_to_hot": {"key": "tierToHot", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + tier_to_cold: Optional["_models.DateAfterCreation"] = None, + tier_to_hot: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tier_to_cool: The function to tier blob snapshot to cool storage. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword tier_to_archive: The function to tier blob snapshot to archive storage. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword tier_to_cold: The function to tier blobs to cold storage. + :paramtype tier_to_cold: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword tier_to_hot: The function to tier blobs to hot storage. This action can only be used + with Premium Block Blob Storage Accounts. + :paramtype tier_to_hot: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword delete: The function to delete the blob snapshot. + :paramtype delete: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + """ + super().__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.tier_to_cold = tier_to_cold + self.tier_to_hot = tier_to_hot + self.delete = delete + + +class ManagementPolicyVersion(_serialization.Model): + """Management policy action for blob version. + + :ivar tier_to_cool: The function to tier blob version to cool storage. + :vartype tier_to_cool: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar tier_to_archive: The function to tier blob version to archive storage. + :vartype tier_to_archive: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar tier_to_cold: The function to tier blobs to cold storage. + :vartype tier_to_cold: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar tier_to_hot: The function to tier blobs to hot storage. This action can only be used with + Premium Block Blob Storage Accounts. + :vartype tier_to_hot: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :ivar delete: The function to delete the blob version. + :vartype delete: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + """ + + _attribute_map = { + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "tier_to_cold": {"key": "tierToCold", "type": "DateAfterCreation"}, + "tier_to_hot": {"key": "tierToHot", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + tier_to_cold: Optional["_models.DateAfterCreation"] = None, + tier_to_hot: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tier_to_cool: The function to tier blob version to cool storage. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword tier_to_archive: The function to tier blob version to archive storage. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword tier_to_cold: The function to tier blobs to cold storage. + :paramtype tier_to_cold: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword tier_to_hot: The function to tier blobs to hot storage. This action can only be used + with Premium Block Blob Storage Accounts. + :paramtype tier_to_hot: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + :keyword delete: The function to delete the blob version. + :paramtype delete: ~azure.mgmt.storage.v2023_05_01.models.DateAfterCreation + """ + super().__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.tier_to_cold = tier_to_cold + self.tier_to_hot = tier_to_hot + self.delete = delete + + +class MetricSpecification(_serialization.Model): + """Metric specification of operation. + + :ivar name: Name of metric specification. + :vartype name: str + :ivar display_name: Display name of metric specification. + :vartype display_name: str + :ivar display_description: Display description of metric specification. + :vartype display_description: str + :ivar unit: Unit could be Bytes or Count. + :vartype unit: str + :ivar dimensions: Dimensions of blobs, including blob type and access tier. + :vartype dimensions: list[~azure.mgmt.storage.v2023_05_01.models.Dimension] + :ivar aggregation_type: Aggregation type could be Average. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: The property to decide fill gap with zero or not. + :vartype fill_gap_with_zero: bool + :ivar category: The category this metric specification belong to, could be Capacity. + :vartype category: str + :ivar resource_id_dimension_name_override: Account Resource Id. + :vartype resource_id_dimension_name_override: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + dimensions: Optional[List["_models.Dimension"]] = None, + aggregation_type: Optional[str] = None, + fill_gap_with_zero: Optional[bool] = None, + category: Optional[str] = None, + resource_id_dimension_name_override: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of metric specification. + :paramtype name: str + :keyword display_name: Display name of metric specification. + :paramtype display_name: str + :keyword display_description: Display description of metric specification. + :paramtype display_description: str + :keyword unit: Unit could be Bytes or Count. + :paramtype unit: str + :keyword dimensions: Dimensions of blobs, including blob type and access tier. + :paramtype dimensions: list[~azure.mgmt.storage.v2023_05_01.models.Dimension] + :keyword aggregation_type: Aggregation type could be Average. + :paramtype aggregation_type: str + :keyword fill_gap_with_zero: The property to decide fill gap with zero or not. + :paramtype fill_gap_with_zero: bool + :keyword category: The category this metric specification belong to, could be Capacity. + :paramtype category: str + :keyword resource_id_dimension_name_override: Account Resource Id. + :paramtype resource_id_dimension_name_override: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.dimensions = dimensions + self.aggregation_type = aggregation_type + self.fill_gap_with_zero = fill_gap_with_zero + self.category = category + self.resource_id_dimension_name_override = resource_id_dimension_name_override + + +class Multichannel(_serialization.Model): + """Multichannel setting. Applies to Premium FileStorage only. + + :ivar enabled: Indicates whether multichannel is enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Indicates whether multichannel is enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class NetworkRuleSet(_serialization.Model): + """Network rule set. + + All required parameters must be populated in order to send to server. + + :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible + values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". + :vartype bypass: str or ~azure.mgmt.storage.v2023_05_01.models.Bypass + :ivar resource_access_rules: Sets the resource access rules. + :vartype resource_access_rules: list[~azure.mgmt.storage.v2023_05_01.models.ResourceAccessRule] + :ivar virtual_network_rules: Sets the virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.storage.v2023_05_01.models.VirtualNetworkRule] + :ivar ip_rules: Sets the IP ACL rules. + :vartype ip_rules: list[~azure.mgmt.storage.v2023_05_01.models.IPRule] + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.storage.v2023_05_01.models.DefaultAction + """ + + _validation = { + "default_action": {"required": True}, + } + + _attribute_map = { + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, + } + + def __init__( + self, + *, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Union[str, "_models.Bypass"] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. + Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", and "AzureServices". + :paramtype bypass: str or ~azure.mgmt.storage.v2023_05_01.models.Bypass + :keyword resource_access_rules: Sets the resource access rules. + :paramtype resource_access_rules: + list[~azure.mgmt.storage.v2023_05_01.models.ResourceAccessRule] + :keyword virtual_network_rules: Sets the virtual network rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.storage.v2023_05_01.models.VirtualNetworkRule] + :keyword ip_rules: Sets the IP ACL rules. + :paramtype ip_rules: list[~azure.mgmt.storage.v2023_05_01.models.IPRule] + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". + :paramtype default_action: str or ~azure.mgmt.storage.v2023_05_01.models.DefaultAction + """ + super().__init__(**kwargs) + self.bypass = bypass + self.resource_access_rules = resource_access_rules + self.virtual_network_rules = virtual_network_rules + self.ip_rules = ip_rules + self.default_action = default_action + + +class NetworkSecurityPerimeter(_serialization.Model): + """NetworkSecurityPerimeter related information. + + :ivar id: The ARM identifier of the resource. + :vartype id: str + :ivar perimeter_guid: Guid of the resource. + :vartype perimeter_guid: str + :ivar location: Location of the resource. + :vartype location: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "perimeter_guid": {"key": "perimeterGuid", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The ARM identifier of the resource. + :paramtype id: str + :keyword perimeter_guid: Guid of the resource. + :paramtype perimeter_guid: str + :keyword location: Location of the resource. + :paramtype location: str + """ + super().__init__(**kwargs) + self.id = id + self.perimeter_guid = perimeter_guid + self.location = location + + +class ResourceAutoGenerated(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/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 + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.storage.v2023_05_01.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) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResourceAutoGenerated(ResourceAutoGenerated): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + 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}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.storage.v2023_05_01.models.SystemData + """ + + +class NetworkSecurityPerimeterConfiguration(ProxyResourceAutoGenerated): + """The Network Security Perimeter configuration 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}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.storage.v2023_05_01.models.SystemData + :ivar provisioning_state: Provisioning state of Network Security Perimeter configuration + propagation. Known values are: "Accepted", "Succeeded", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfigurationProvisioningState + :ivar provisioning_issues: List of Provisioning Issues if any. + :vartype provisioning_issues: list[~azure.mgmt.storage.v2023_05_01.models.ProvisioningIssue] + :ivar network_security_perimeter: NetworkSecurityPerimeter related information. + :vartype network_security_perimeter: + ~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeter + :ivar resource_association: Information about resource association. + :vartype resource_association: + ~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfigurationPropertiesResourceAssociation + :ivar profile: Network Security Perimeter profile. + :vartype profile: + ~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfigurationPropertiesProfile + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "provisioning_issues": {"readonly": True}, + "network_security_perimeter": {"readonly": True}, + "resource_association": {"readonly": True}, + "profile": {"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"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "provisioning_issues": {"key": "properties.provisioningIssues", "type": "[ProvisioningIssue]"}, + "network_security_perimeter": { + "key": "properties.networkSecurityPerimeter", + "type": "NetworkSecurityPerimeter", + }, + "resource_association": { + "key": "properties.resourceAssociation", + "type": "NetworkSecurityPerimeterConfigurationPropertiesResourceAssociation", + }, + "profile": {"key": "properties.profile", "type": "NetworkSecurityPerimeterConfigurationPropertiesProfile"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.provisioning_issues = None + self.network_security_perimeter = None + self.resource_association = None + self.profile = None + + +class NetworkSecurityPerimeterConfigurationList(_serialization.Model): # pylint: disable=name-too-long + """Result of the List Network Security Perimeter configuration operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A collection of Network Security Perimeter configurations. + :vartype value: + list[~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfiguration] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkSecurityPerimeterConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = None + self.next_link = next_link + + +class NetworkSecurityPerimeterConfigurationPropertiesProfile(_serialization.Model): # pylint: disable=name-too-long + """Network Security Perimeter profile. + + :ivar name: Name of the resource. + :vartype name: str + :ivar access_rules_version: Current access rules version. + :vartype access_rules_version: float + :ivar access_rules: List of Access Rules. + :vartype access_rules: list[~azure.mgmt.storage.v2023_05_01.models.NspAccessRule] + :ivar diagnostic_settings_version: Diagnostic settings version. + :vartype diagnostic_settings_version: float + :ivar enabled_log_categories: Enabled logging categories. + :vartype enabled_log_categories: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "access_rules_version": {"key": "accessRulesVersion", "type": "float"}, + "access_rules": {"key": "accessRules", "type": "[NspAccessRule]"}, + "diagnostic_settings_version": {"key": "diagnosticSettingsVersion", "type": "float"}, + "enabled_log_categories": {"key": "enabledLogCategories", "type": "[str]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + access_rules_version: Optional[float] = None, + access_rules: Optional[List["_models.NspAccessRule"]] = None, + diagnostic_settings_version: Optional[float] = None, + enabled_log_categories: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the resource. + :paramtype name: str + :keyword access_rules_version: Current access rules version. + :paramtype access_rules_version: float + :keyword access_rules: List of Access Rules. + :paramtype access_rules: list[~azure.mgmt.storage.v2023_05_01.models.NspAccessRule] + :keyword diagnostic_settings_version: Diagnostic settings version. + :paramtype diagnostic_settings_version: float + :keyword enabled_log_categories: Enabled logging categories. + :paramtype enabled_log_categories: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.access_rules_version = access_rules_version + self.access_rules = access_rules + self.diagnostic_settings_version = diagnostic_settings_version + self.enabled_log_categories = enabled_log_categories + + +class NetworkSecurityPerimeterConfigurationPropertiesResourceAssociation( + _serialization.Model +): # pylint: disable=name-too-long + """Information about resource association. + + :ivar name: Name of the resource association. + :vartype name: str + :ivar access_mode: Access Mode of the resource association. Known values are: "Enforced", + "Learning", and "Audit". + :vartype access_mode: str or + ~azure.mgmt.storage.v2023_05_01.models.ResourceAssociationAccessMode + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "access_mode": {"key": "accessMode", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + access_mode: Optional[Union[str, "_models.ResourceAssociationAccessMode"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the resource association. + :paramtype name: str + :keyword access_mode: Access Mode of the resource association. Known values are: "Enforced", + "Learning", and "Audit". + :paramtype access_mode: str or + ~azure.mgmt.storage.v2023_05_01.models.ResourceAssociationAccessMode + """ + super().__init__(**kwargs) + self.name = name + self.access_mode = access_mode + + +class NspAccessRule(_serialization.Model): + """Information of Access Rule in Network Security Perimeter profile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the resource. + :vartype name: str + :ivar properties: Properties of Access Rule. + :vartype properties: ~azure.mgmt.storage.v2023_05_01.models.NspAccessRuleProperties + """ + + _validation = { + "properties": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "NspAccessRuleProperties"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the resource. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.properties = None + + +class NspAccessRuleProperties(_serialization.Model): + """Properties of Access Rule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar direction: Direction of Access Rule. Known values are: "Inbound" and "Outbound". + :vartype direction: str or ~azure.mgmt.storage.v2023_05_01.models.NspAccessRuleDirection + :ivar address_prefixes: Address prefixes in the CIDR format for inbound rules. + :vartype address_prefixes: list[str] + :ivar subscriptions: Subscriptions for inbound rules. + :vartype subscriptions: + list[~azure.mgmt.storage.v2023_05_01.models.NspAccessRulePropertiesSubscriptionsItem] + :ivar network_security_perimeters: NetworkSecurityPerimeters for inbound rules. + :vartype network_security_perimeters: + list[~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeter] + :ivar fully_qualified_domain_names: FQDN for outbound rules. + :vartype fully_qualified_domain_names: list[str] + """ + + _validation = { + "network_security_perimeters": {"readonly": True}, + "fully_qualified_domain_names": {"readonly": True}, + } + + _attribute_map = { + "direction": {"key": "direction", "type": "str"}, + "address_prefixes": {"key": "addressPrefixes", "type": "[str]"}, + "subscriptions": {"key": "subscriptions", "type": "[NspAccessRulePropertiesSubscriptionsItem]"}, + "network_security_perimeters": {"key": "networkSecurityPerimeters", "type": "[NetworkSecurityPerimeter]"}, + "fully_qualified_domain_names": {"key": "fullyQualifiedDomainNames", "type": "[str]"}, + } + + def __init__( + self, + *, + direction: Optional[Union[str, "_models.NspAccessRuleDirection"]] = None, + address_prefixes: Optional[List[str]] = None, + subscriptions: Optional[List["_models.NspAccessRulePropertiesSubscriptionsItem"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword direction: Direction of Access Rule. Known values are: "Inbound" and "Outbound". + :paramtype direction: str or ~azure.mgmt.storage.v2023_05_01.models.NspAccessRuleDirection + :keyword address_prefixes: Address prefixes in the CIDR format for inbound rules. + :paramtype address_prefixes: list[str] + :keyword subscriptions: Subscriptions for inbound rules. + :paramtype subscriptions: + list[~azure.mgmt.storage.v2023_05_01.models.NspAccessRulePropertiesSubscriptionsItem] + """ + super().__init__(**kwargs) + self.direction = direction + self.address_prefixes = address_prefixes + self.subscriptions = subscriptions + self.network_security_perimeters = None + self.fully_qualified_domain_names = None + + +class NspAccessRulePropertiesSubscriptionsItem(_serialization.Model): + """Subscription for inbound rule. + + :ivar id: The ARM identifier of subscription. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The ARM identifier of subscription. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class ObjectReplicationPolicies(_serialization.Model): + """List storage account object replication policies. + + :ivar value: The replication policy between two storage accounts. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, + } + + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The replication policy between two storage accounts. + :paramtype value: list[~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy] + """ + super().__init__(**kwargs) + self.value = value + + +class ObjectReplicationPolicy(Resource): + """The replication policy between two storage accounts. Multiple rules can be defined in one + policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar policy_id: A unique id for object replication policy. + :vartype policy_id: str + :ivar enabled_time: Indicates when the policy is enabled on the source account. + :vartype enabled_time: ~datetime.datetime + :ivar source_account: Required. Source account name. It should be full resource id if + allowCrossTenantReplication set to false. + :vartype source_account: str + :ivar destination_account: Required. Destination account name. It should be full resource id if + allowCrossTenantReplication set to false. + :vartype destination_account: str + :ivar rules: The storage account object replication rules. + :vartype rules: list[~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicyRule] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, + } + + def __init__( + self, + *, + source_account: Optional[str] = None, + destination_account: Optional[str] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword source_account: Required. Source account name. It should be full resource id if + allowCrossTenantReplication set to false. + :paramtype source_account: str + :keyword destination_account: Required. Destination account name. It should be full resource id + if allowCrossTenantReplication set to false. + :paramtype destination_account: str + :keyword rules: The storage account object replication rules. + :paramtype rules: list[~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicyRule] + """ + super().__init__(**kwargs) + self.policy_id = None + self.enabled_time = None + self.source_account = source_account + self.destination_account = destination_account + self.rules = rules + + +class ObjectReplicationPolicyFilter(_serialization.Model): + """Filters limit replication to a subset of blobs within the storage account. A logical OR is + performed on values in the filter. If multiple filters are defined, a logical AND is performed + on all filters. + + :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin + with the specified prefix. + :vartype prefix_match: list[str] + :ivar min_creation_time: Blobs created after the time will be replicated to the destination. It + must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. + :vartype min_creation_time: str + """ + + _attribute_map = { + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, + } + + def __init__( + self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin + with the specified prefix. + :paramtype prefix_match: list[str] + :keyword min_creation_time: Blobs created after the time will be replicated to the destination. + It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. + :paramtype min_creation_time: str + """ + super().__init__(**kwargs) + self.prefix_match = prefix_match + self.min_creation_time = min_creation_time + + +class ObjectReplicationPolicyRule(_serialization.Model): + """The replication policy rule between two containers. + + All required parameters must be populated in order to send to server. + + :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is + required for put policy on source account. + :vartype rule_id: str + :ivar source_container: Required. Source container name. Required. + :vartype source_container: str + :ivar destination_container: Required. Destination container name. Required. + :vartype destination_container: str + :ivar filters: Optional. An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicyFilter + """ + + _validation = { + "source_container": {"required": True}, + "destination_container": {"required": True}, + } + + _attribute_map = { + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, + } + + def __init__( + self, + *, + source_container: str, + destination_container: str, + rule_id: Optional[str] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, + **kwargs: Any + ) -> None: + """ + :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is + required for put policy on source account. + :paramtype rule_id: str + :keyword source_container: Required. Source container name. Required. + :paramtype source_container: str + :keyword destination_container: Required. Destination container name. Required. + :paramtype destination_container: str + :keyword filters: Optional. An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicyFilter + """ + super().__init__(**kwargs) + self.rule_id = rule_id + self.source_container = source_container + self.destination_container = destination_container + self.filters = filters + + +class Operation(_serialization.Model): + """Storage REST API operation definition. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.storage.v2023_05_01.models.OperationDisplay + :ivar origin: The origin of operations. + :vartype origin: str + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: ~azure.mgmt.storage.v2023_05_01.models.ServiceSpecification + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.storage.v2023_05_01.models.OperationDisplay + :keyword origin: The origin of operations. + :paramtype origin: str + :keyword service_specification: One property of operation, include metric specifications. + :paramtype service_specification: ~azure.mgmt.storage.v2023_05_01.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + self.service_specification = service_specification + + +class OperationDisplay(_serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Service provider: Microsoft Storage. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _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, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword provider: Service provider: Microsoft Storage. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed etc. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(_serialization.Model): + """Result of the request to list Storage operations. It contains a list of operations and a URL + link to get the next set of results. + + :ivar value: List of Storage operations supported by the Storage resource provider. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.Operation] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + } + + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of Storage operations supported by the Storage resource provider. + :paramtype value: list[~azure.mgmt.storage.v2023_05_01.models.Operation] + """ + super().__init__(**kwargs) + self.value = value + + +class PermissionScope(_serialization.Model): + """PermissionScope. + + All required parameters must be populated in order to send to server. + + :ivar permissions: The permissions for the local user. Possible values include: Read (r), Write + (w), Delete (d), List (l), Create (c), Modify Ownership (o), and Modify Permissions (p). + Required. + :vartype permissions: str + :ivar service: The service used by the local user, e.g. blob, file. Required. + :vartype service: str + :ivar resource_name: The name of resource, normally the container name or the file share name, + used by the local user. Required. + :vartype resource_name: str + """ + + _validation = { + "permissions": {"required": True}, + "service": {"required": True}, + "resource_name": {"required": True}, + } + + _attribute_map = { + "permissions": {"key": "permissions", "type": "str"}, + "service": {"key": "service", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + } + + def __init__(self, *, permissions: str, service: str, resource_name: str, **kwargs: Any) -> None: + """ + :keyword permissions: The permissions for the local user. Possible values include: Read (r), + Write (w), Delete (d), List (l), Create (c), Modify Ownership (o), and Modify Permissions (p). + Required. + :paramtype permissions: str + :keyword service: The service used by the local user, e.g. blob, file. Required. + :paramtype service: str + :keyword resource_name: The name of resource, normally the container name or the file share + name, used by the local user. Required. + :paramtype resource_name: str + """ + super().__init__(**kwargs) + self.permissions = permissions + self.service = service + self.resource_name = resource_name + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(Resource): + """The Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.storage.v2023_05_01.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.storage.v2023_05_01.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """List of private endpoint connection associated with the specified storage account. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkResource(Resource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id = None + self.required_members = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.storage.v2023_05_01.models.PrivateLinkResource] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar action_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype action_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + action_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or + ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword action_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype action_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.action_required = action_required + + +class ProtectedAppendWritesHistory(_serialization.Model): + """Protected append writes history setting for the blob container with Legal holds. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes_all: bool + :ivar timestamp: Returns the date and time the tag was added. + :vartype timestamp: ~datetime.datetime + """ + + _validation = { + "timestamp": {"readonly": True}, + } + + _attribute_map = { + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + } + + def __init__(self, *, allow_protected_append_writes_all: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.allow_protected_append_writes_all = allow_protected_append_writes_all + self.timestamp = None + + +class ProtocolSettings(_serialization.Model): + """Protocol settings for file service. + + :ivar smb: Setting for SMB protocol. + :vartype smb: ~azure.mgmt.storage.v2023_05_01.models.SmbSetting + """ + + _attribute_map = { + "smb": {"key": "smb", "type": "SmbSetting"}, + } + + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs: Any) -> None: + """ + :keyword smb: Setting for SMB protocol. + :paramtype smb: ~azure.mgmt.storage.v2023_05_01.models.SmbSetting + """ + super().__init__(**kwargs) + self.smb = smb + + +class ProvisioningIssue(_serialization.Model): + """Describes provisioning issue for given NetworkSecurityPerimeterConfiguration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the issue. + :vartype name: str + :ivar properties: Properties of provisioning issue. + :vartype properties: ~azure.mgmt.storage.v2023_05_01.models.ProvisioningIssueProperties + """ + + _validation = { + "properties": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ProvisioningIssueProperties"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the issue. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + self.properties = None + + +class ProvisioningIssueProperties(_serialization.Model): + """Properties of provisioning issue. + + :ivar issue_type: Type of issue. Known values are: "Unknown" and + "ConfigurationPropagationFailure". + :vartype issue_type: str or ~azure.mgmt.storage.v2023_05_01.models.IssueType + :ivar severity: Severity of the issue. Known values are: "Warning" and "Error". + :vartype severity: str or ~azure.mgmt.storage.v2023_05_01.models.Severity + :ivar description: Description of the issue. + :vartype description: str + """ + + _attribute_map = { + "issue_type": {"key": "issueType", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + issue_type: Optional[Union[str, "_models.IssueType"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword issue_type: Type of issue. Known values are: "Unknown" and + "ConfigurationPropagationFailure". + :paramtype issue_type: str or ~azure.mgmt.storage.v2023_05_01.models.IssueType + :keyword severity: Severity of the issue. Known values are: "Warning" and "Error". + :paramtype severity: str or ~azure.mgmt.storage.v2023_05_01.models.Severity + :keyword description: Description of the issue. + :paramtype description: str + """ + super().__init__(**kwargs) + self.issue_type = issue_type + self.severity = severity + self.description = description + + +class QueueServiceProperties(Resource): + """The properties of a storage account’s Queue service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Queue service. + :vartype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + } + + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) -> None: + """ + :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Queue service. + :paramtype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + """ + super().__init__(**kwargs) + self.cors = cors + + +class ResourceAccessRule(_serialization.Model): + """Resource Access Rule. + + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar resource_id: Resource Id. + :vartype resource_id: str + """ + + _attribute_map = { + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + } + + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword tenant_id: Tenant Id. + :paramtype tenant_id: str + :keyword resource_id: Resource Id. + :paramtype resource_id: str + """ + super().__init__(**kwargs) + self.tenant_id = tenant_id + self.resource_id = resource_id + + +class RestorePolicyProperties(_serialization.Model): + """The blob service properties for blob restore policy. + + 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 enabled: Blob restore is enabled if set to true. Required. + :vartype enabled: bool + :ivar days: how long this blob can be restored. It should be great than zero and less than + DeleteRetentionPolicy.days. + :vartype days: int + :ivar last_enabled_time: Deprecated in favor of minRestoreTime property. + :vartype last_enabled_time: ~datetime.datetime + :ivar min_restore_time: Returns the minimum date and time that the restore can be started. + :vartype min_restore_time: ~datetime.datetime + """ + + _validation = { + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, + } + + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Blob restore is enabled if set to true. Required. + :paramtype enabled: bool + :keyword days: how long this blob can be restored. It should be great than zero and less than + DeleteRetentionPolicy.days. + :paramtype days: int + """ + super().__init__(**kwargs) + self.enabled = enabled + self.days = days + self.last_enabled_time = None + self.min_restore_time = None + + +class Restriction(_serialization.Model): + """The restriction because of which SKU cannot be used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of restrictions. As of now only possible value for this is location. + :vartype type: str + :ivar values: The value of restrictions. If the restriction type is set to location. This would + be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". + :vartype reason_code: str or ~azure.mgmt.storage.v2023_05_01.models.ReasonCode + """ + + _validation = { + "type": {"readonly": True}, + "values": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + } + + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs: Any) -> None: + """ + :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". + :paramtype reason_code: str or ~azure.mgmt.storage.v2023_05_01.models.ReasonCode + """ + super().__init__(**kwargs) + self.type = None + self.values = None + self.reason_code = reason_code + + +class RoutingPreference(_serialization.Model): + """Routing preference defines the type of network, either microsoft or internet routing to be used + to deliver the user data, the default option is microsoft routing. + + :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. + Known values are: "MicrosoftRouting" and "InternetRouting". + :vartype routing_choice: str or ~azure.mgmt.storage.v2023_05_01.models.RoutingChoice + :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing + storage endpoints are to be published. + :vartype publish_microsoft_endpoints: bool + :ivar publish_internet_endpoints: A boolean flag which indicates whether internet routing + storage endpoints are to be published. + :vartype publish_internet_endpoints: bool + """ + + _attribute_map = { + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, + } + + def __init__( + self, + *, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, + publish_microsoft_endpoints: Optional[bool] = None, + publish_internet_endpoints: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. + Known values are: "MicrosoftRouting" and "InternetRouting". + :paramtype routing_choice: str or ~azure.mgmt.storage.v2023_05_01.models.RoutingChoice + :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing + storage endpoints are to be published. + :paramtype publish_microsoft_endpoints: bool + :keyword publish_internet_endpoints: A boolean flag which indicates whether internet routing + storage endpoints are to be published. + :paramtype publish_internet_endpoints: bool + """ + super().__init__(**kwargs) + self.routing_choice = routing_choice + self.publish_microsoft_endpoints = publish_microsoft_endpoints + self.publish_internet_endpoints = publish_internet_endpoints + + +class SasPolicy(_serialization.Model): + """SasPolicy assigned to the storage account. + + All required parameters must be populated in order to send to server. + + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. + :vartype sas_expiration_period: str + :ivar expiration_action: The SAS Expiration Action defines the action to be performed when + sasPolicy.sasExpirationPeriod is violated. The 'Log' action can be used for audit purposes and + the 'Block' action can be used to block and deny the usage of SAS tokens that do not adhere to + the sas policy expiration period. Known values are: "Log" and "Block". + :vartype expiration_action: str or ~azure.mgmt.storage.v2023_05_01.models.ExpirationAction + """ + + _validation = { + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, + } + + _attribute_map = { + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, + } + + def __init__( + self, + *, + sas_expiration_period: str, + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", + **kwargs: Any + ) -> None: + """ + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. + :paramtype sas_expiration_period: str + :keyword expiration_action: The SAS Expiration Action defines the action to be performed when + sasPolicy.sasExpirationPeriod is violated. The 'Log' action can be used for audit purposes and + the 'Block' action can be used to block and deny the usage of SAS tokens that do not adhere to + the sas policy expiration period. Known values are: "Log" and "Block". + :paramtype expiration_action: str or ~azure.mgmt.storage.v2023_05_01.models.ExpirationAction + """ + super().__init__(**kwargs) + self.sas_expiration_period = sas_expiration_period + self.expiration_action = expiration_action + + +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters to list service SAS credentials of a specific resource. + + All required parameters must be populated in order to send to server. + + :ivar canonicalized_resource: The canonical path to the signed resource. Required. + :vartype canonicalized_resource: str + :ivar resource: The signed services accessible with the service SAS. Possible values include: + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". + :vartype resource: str or ~azure.mgmt.storage.v2023_05_01.models.SignedResource + :ivar permissions: The signed permissions for the service SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :vartype permissions: str or ~azure.mgmt.storage.v2023_05_01.models.Permissions + :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :vartype ip_address_or_range: str + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http" and "https". + :vartype protocols: str or ~azure.mgmt.storage.v2023_05_01.models.HttpProtocol + :ivar shared_access_start_time: The time at which the SAS becomes valid. + :vartype shared_access_start_time: ~datetime.datetime + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + :vartype shared_access_expiry_time: ~datetime.datetime + :ivar identifier: A unique value up to 64 characters in length that correlates to an access + policy specified for the container, queue, or table. + :vartype identifier: str + :ivar partition_key_start: The start of partition key. + :vartype partition_key_start: str + :ivar partition_key_end: The end of partition key. + :vartype partition_key_end: str + :ivar row_key_start: The start of row key. + :vartype row_key_start: str + :ivar row_key_end: The end of row key. + :vartype row_key_end: str + :ivar key_to_sign: The key to sign the account SAS token with. + :vartype key_to_sign: str + :ivar cache_control: The response header override for cache control. + :vartype cache_control: str + :ivar content_disposition: The response header override for content disposition. + :vartype content_disposition: str + :ivar content_encoding: The response header override for content encoding. + :vartype content_encoding: str + :ivar content_language: The response header override for content language. + :vartype content_language: str + :ivar content_type: The response header override for content type. + :vartype content_type: str + """ + + _validation = { + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, + } + + def __init__( + self, + *, + canonicalized_resource: str, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, + ip_address_or_range: Optional[str] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, + shared_access_start_time: Optional[datetime.datetime] = None, + shared_access_expiry_time: Optional[datetime.datetime] = None, + identifier: Optional[str] = None, + partition_key_start: Optional[str] = None, + partition_key_end: Optional[str] = None, + row_key_start: Optional[str] = None, + row_key_end: Optional[str] = None, + key_to_sign: Optional[str] = None, + cache_control: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword canonicalized_resource: The canonical path to the signed resource. Required. + :paramtype canonicalized_resource: str + :keyword resource: The signed services accessible with the service SAS. Possible values + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". + :paramtype resource: str or ~azure.mgmt.storage.v2023_05_01.models.SignedResource + :keyword permissions: The signed permissions for the service SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :paramtype permissions: str or ~azure.mgmt.storage.v2023_05_01.models.Permissions + :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :paramtype ip_address_or_range: str + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http" and "https". + :paramtype protocols: str or ~azure.mgmt.storage.v2023_05_01.models.HttpProtocol + :keyword shared_access_start_time: The time at which the SAS becomes valid. + :paramtype shared_access_start_time: ~datetime.datetime + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. + :paramtype shared_access_expiry_time: ~datetime.datetime + :keyword identifier: A unique value up to 64 characters in length that correlates to an access + policy specified for the container, queue, or table. + :paramtype identifier: str + :keyword partition_key_start: The start of partition key. + :paramtype partition_key_start: str + :keyword partition_key_end: The end of partition key. + :paramtype partition_key_end: str + :keyword row_key_start: The start of row key. + :paramtype row_key_start: str + :keyword row_key_end: The end of row key. + :paramtype row_key_end: str + :keyword key_to_sign: The key to sign the account SAS token with. + :paramtype key_to_sign: str + :keyword cache_control: The response header override for cache control. + :paramtype cache_control: str + :keyword content_disposition: The response header override for content disposition. + :paramtype content_disposition: str + :keyword content_encoding: The response header override for content encoding. + :paramtype content_encoding: str + :keyword content_language: The response header override for content language. + :paramtype content_language: str + :keyword content_type: The response header override for content type. + :paramtype content_type: str + """ + super().__init__(**kwargs) + self.canonicalized_resource = canonicalized_resource + self.resource = resource + self.permissions = permissions + self.ip_address_or_range = ip_address_or_range + self.protocols = protocols + self.shared_access_start_time = shared_access_start_time + self.shared_access_expiry_time = shared_access_expiry_time + self.identifier = identifier + self.partition_key_start = partition_key_start + self.partition_key_end = partition_key_end + self.row_key_start = row_key_start + self.row_key_end = row_key_end + self.key_to_sign = key_to_sign + self.cache_control = cache_control + self.content_disposition = content_disposition + self.content_encoding = content_encoding + self.content_language = content_language + self.content_type = content_type + + +class ServiceSpecification(_serialization.Model): + """One property of operation, include metric specifications. + + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: + list[~azure.mgmt.storage.v2023_05_01.models.MetricSpecification] + """ + + _attribute_map = { + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + } + + def __init__( + self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs: Any + ) -> None: + """ + :keyword metric_specifications: Metric specifications of operation. + :paramtype metric_specifications: + list[~azure.mgmt.storage.v2023_05_01.models.MetricSpecification] + """ + super().__init__(**kwargs) + self.metric_specifications = metric_specifications + + +class SignedIdentifier(_serialization.Model): + """SignedIdentifier. + + :ivar id: An unique identifier of the stored access policy. + :vartype id: str + :ivar access_policy: Access policy. + :vartype access_policy: ~azure.mgmt.storage.v2023_05_01.models.AccessPolicy + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + access_policy: Optional["_models.AccessPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: An unique identifier of the stored access policy. + :paramtype id: str + :keyword access_policy: Access policy. + :paramtype access_policy: ~azure.mgmt.storage.v2023_05_01.models.AccessPolicy + """ + super().__init__(**kwargs) + self.id = id + self.access_policy = access_policy + + +class Sku(_serialization.Model): + """The SKU of the storage account. + + 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 name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :vartype name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and + "Premium". + :vartype tier: str or ~azure.mgmt.storage.v2023_05_01.models.SkuTier + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: + """ + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :paramtype name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class SKUCapability(_serialization.Model): + """The capability information in the specified SKU, including file encryption, network ACLs, + change notification, etc. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of capability, The capability information in the specified SKU, including + file encryption, network ACLs, change notification, etc. + :vartype name: str + :ivar value: A string value to indicate states of given capability. Possibly 'true' or 'false'. + :vartype value: str + """ + + _validation = { + "name": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.value = None + + +class SkuInformation(_serialization.Model): + """Storage SKU and its 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 name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :vartype name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and + "Premium". + :vartype tier: str or ~azure.mgmt.storage.v2023_05_01.models.SkuTier + :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. + :vartype resource_type: str + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2023_05_01.models.Kind + :ivar locations: The set of locations that the SKU is available. This will be supported and + registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). + :vartype locations: list[str] + :ivar capabilities: The capability information in the specified SKU, including file encryption, + network ACLs, change notification, etc. + :vartype capabilities: list[~azure.mgmt.storage.v2023_05_01.models.SKUCapability] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.storage.v2023_05_01.models.Restriction] + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, + } + + def __init__( + self, + *, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :paramtype name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :paramtype restrictions: list[~azure.mgmt.storage.v2023_05_01.models.Restriction] + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + self.resource_type = None + self.kind = None + self.locations = None + self.capabilities = None + self.restrictions = restrictions + + +class SmbSetting(_serialization.Model): + """Setting for SMB protocol. + + :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. + :vartype multichannel: ~azure.mgmt.storage.v2023_05_01.models.Multichannel + :ivar versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, + SMB3.1.1. Should be passed as a string with delimiter ';'. + :vartype versions: str + :ivar authentication_methods: SMB authentication methods supported by server. Valid values are + NTLMv2, Kerberos. Should be passed as a string with delimiter ';'. + :vartype authentication_methods: str + :ivar kerberos_ticket_encryption: Kerberos ticket encryption supported by server. Valid values + are RC4-HMAC, AES-256. Should be passed as a string with delimiter ';'. + :vartype kerberos_ticket_encryption: str + :ivar channel_encryption: SMB channel encryption supported by server. Valid values are + AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. + :vartype channel_encryption: str + """ + + _attribute_map = { + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, + } + + def __init__( + self, + *, + multichannel: Optional["_models.Multichannel"] = None, + versions: Optional[str] = None, + authentication_methods: Optional[str] = None, + kerberos_ticket_encryption: Optional[str] = None, + channel_encryption: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword multichannel: Multichannel setting. Applies to Premium FileStorage only. + :paramtype multichannel: ~azure.mgmt.storage.v2023_05_01.models.Multichannel + :keyword versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, + SMB3.1.1. Should be passed as a string with delimiter ';'. + :paramtype versions: str + :keyword authentication_methods: SMB authentication methods supported by server. Valid values + are NTLMv2, Kerberos. Should be passed as a string with delimiter ';'. + :paramtype authentication_methods: str + :keyword kerberos_ticket_encryption: Kerberos ticket encryption supported by server. Valid + values are RC4-HMAC, AES-256. Should be passed as a string with delimiter ';'. + :paramtype kerberos_ticket_encryption: str + :keyword channel_encryption: SMB channel encryption supported by server. Valid values are + AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. + :paramtype channel_encryption: str + """ + super().__init__(**kwargs) + self.multichannel = multichannel + self.versions = versions + self.authentication_methods = authentication_methods + self.kerberos_ticket_encryption = kerberos_ticket_encryption + self.channel_encryption = channel_encryption + + +class SshPublicKey(_serialization.Model): + """SshPublicKey. + + :ivar description: Optional. It is used to store the function/usage of the key. + :vartype description: str + :ivar key: Ssh public key base64 encoded. The format should be: ':code:`` + :code:``', e.g. ssh-rsa AAAABBBB. + :vartype key: str + """ + + _attribute_map = { + "description": {"key": "description", "type": "str"}, + "key": {"key": "key", "type": "str"}, + } + + def __init__(self, *, description: Optional[str] = None, key: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword description: Optional. It is used to store the function/usage of the key. + :paramtype description: str + :keyword key: Ssh public key base64 encoded. The format should be: ':code:`` + :code:``', e.g. ssh-rsa AAAABBBB. + :paramtype key: str + """ + super().__init__(**kwargs) + self.description = description + self.key = key + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /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 + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes + """The storage account. + + 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 id: Fully qualified resource ID for the resource. Ex - + /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 + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar sku: Gets the SKU. + :vartype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", + "FileStorage", and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2023_05_01.models.Kind + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2023_05_01.models.Identity + :ivar extended_location: The extendedLocation of the resource. + :vartype extended_location: ~azure.mgmt.storage.v2023_05_01.models.ExtendedLocation + :ivar provisioning_state: Gets the status of the storage account at the time the operation was + called. Known values are: "Creating", "ResolvingDNS", "Succeeded", + "ValidateSubscriptionQuotaBegin", "ValidateSubscriptionQuotaEnd", "Deleting", "Canceled", and + "Failed". + :vartype provisioning_state: str or ~azure.mgmt.storage.v2023_05_01.models.ProvisioningState + :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, + queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob + endpoint. + :vartype primary_endpoints: ~azure.mgmt.storage.v2023_05_01.models.Endpoints + :ivar primary_location: Gets the location of the primary data center for the storage account. + :vartype primary_location: str + :ivar status_of_primary: Gets the status indicating whether the primary location of the storage + account is available or unavailable. Known values are: "available" and "unavailable". + :vartype status_of_primary: str or ~azure.mgmt.storage.v2023_05_01.models.AccountStatus + :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to + the secondary location. Only the most recent timestamp is retained. This element is not + returned if there has never been a failover instance. Only available if the accountType is + Standard_GRS or Standard_RAGRS. + :vartype last_geo_failover_time: ~datetime.datetime + :ivar secondary_location: Gets the location of the geo-replicated secondary for the storage + account. Only available if the accountType is Standard_GRS or Standard_RAGRS. + :vartype secondary_location: str + :ivar status_of_secondary: Gets the status indicating whether the secondary location of the + storage account is available or unavailable. Only available if the SKU name is Standard_GRS or + Standard_RAGRS. Known values are: "available" and "unavailable". + :vartype status_of_secondary: str or ~azure.mgmt.storage.v2023_05_01.models.AccountStatus + :ivar creation_time: Gets the creation date and time of the storage account in UTC. + :vartype creation_time: ~datetime.datetime + :ivar custom_domain: Gets the custom domain the user assigned to this storage account. + :vartype custom_domain: ~azure.mgmt.storage.v2023_05_01.models.CustomDomain + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2023_05_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2023_05_01.models.KeyPolicy + :ivar key_creation_time: Storage account keys creation time. + :vartype key_creation_time: ~azure.mgmt.storage.v2023_05_01.models.KeyCreationTime + :ivar secondary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, + queue, or table object from the secondary location of the storage account. Only available if + the SKU name is Standard_RAGRS. + :vartype secondary_endpoints: ~azure.mgmt.storage.v2023_05_01.models.Endpoints + :ivar encryption: Encryption settings to be used for server-side encryption for the storage + account. + :vartype encryption: ~azure.mgmt.storage.v2023_05_01.models.Encryption + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium", and "Cold". + :vartype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2023_05_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + :vartype enable_https_traffic_only: bool + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2023_05_01.models.NetworkRuleSet + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar enable_extended_groups: Enables extended group support with local users feature, if set + to true. + :vartype enable_extended_groups: bool + :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :vartype is_hns_enabled: bool + :ivar geo_replication_stats: Geo Replication Stats. + :vartype geo_replication_stats: ~azure.mgmt.storage.v2023_05_01.models.GeoReplicationStats + :ivar failover_in_progress: If the failover is in progress, the value will be true, otherwise, + it will be null. + :vartype failover_in_progress: bool + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2023_05_01.models.LargeFileSharesState + :ivar private_endpoint_connections: List of private endpoint connection associated with the + specified storage account. + :vartype private_endpoint_connections: + list[~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection] + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2023_05_01.models.RoutingPreference + :ivar blob_restore_status: Blob restore status. + :vartype blob_restore_status: ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is false for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2", and "TLS1_3". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2023_05_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :vartype enable_nfs_v3: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + Set this property to true for new or existing accounts only if object replication policies will + involve storage accounts in different AAD tenants. The default interpretation is false for new + accounts to follow best security practices by default. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar public_network_access: Allow, disallow, or let Network Security Perimeter configuration + to evaluate public network access to Storage Account. Known values are: "Enabled", "Disabled", + and "SecuredByPerimeter". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2023_05_01.models.PublicNetworkAccess + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageAccount + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2023_05_01.models.AllowedCopyScope + :ivar storage_account_sku_conversion_status: This property is readOnly and is set by server + during asynchronous storage account sku conversion operations. + :vartype storage_account_sku_conversion_status: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountSkuConversionStatus + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard" and "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2023_05_01.models.DnsEndpointType + :ivar is_sku_conversion_blocked: This property will be set to true or false on an event of + ongoing migration. Default value is null. + :vartype is_sku_conversion_blocked: bool + :ivar account_migration_in_progress: If customer initiated account migration is in progress, + the value will be true else it will be null. + :vartype account_migration_in_progress: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + "is_sku_conversion_blocked": {"readonly": True}, + "account_migration_in_progress": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "enable_extended_groups": {"key": "properties.enableExtendedGroups", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "storage_account_sku_conversion_status": { + "key": "properties.storageAccountSkuConversionStatus", + "type": "StorageAccountSkuConversionStatus", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + "is_sku_conversion_blocked": {"key": "properties.isSkuConversionBlocked", "type": "bool"}, + "account_migration_in_progress": {"key": "properties.accountMigrationInProgress", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + enable_extended_groups: Optional[bool] = None, + is_hns_enabled: Optional[bool] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + enable_nfs_v3: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + storage_account_sku_conversion_status: Optional["_models.StorageAccountSkuConversionStatus"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2023_05_01.models.Identity + :keyword extended_location: The extendedLocation of the resource. + :paramtype extended_location: ~azure.mgmt.storage.v2023_05_01.models.ExtendedLocation + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2023_05_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword enable_extended_groups: Enables extended group support with local users feature, if + set to true. + :paramtype enable_extended_groups: bool + :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :paramtype is_hns_enabled: bool + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2023_05_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2023_05_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is false for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2", and "TLS1_3". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2023_05_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :paramtype enable_nfs_v3: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + Set this property to true for new or existing accounts only if object replication policies will + involve storage accounts in different AAD tenants. The default interpretation is false for new + accounts to follow best security practices by default. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword public_network_access: Allow, disallow, or let Network Security Perimeter + configuration to evaluate public network access to Storage Account. Known values are: + "Enabled", "Disabled", and "SecuredByPerimeter". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2023_05_01.models.PublicNetworkAccess + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageAccount + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2023_05_01.models.AllowedCopyScope + :keyword storage_account_sku_conversion_status: This property is readOnly and is set by server + during asynchronous storage account sku conversion operations. + :paramtype storage_account_sku_conversion_status: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountSkuConversionStatus + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard" and "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2023_05_01.models.DnsEndpointType + """ + super().__init__(tags=tags, location=location, **kwargs) + self.sku = None + self.kind = None + self.identity = identity + self.extended_location = extended_location + self.provisioning_state = None + self.primary_endpoints = None + self.primary_location = None + self.status_of_primary = None + self.last_geo_failover_time = None + self.secondary_location = None + self.status_of_secondary = None + self.creation_time = None + self.custom_domain = None + self.sas_policy = None + self.key_policy = None + self.key_creation_time = None + self.secondary_endpoints = None + self.encryption = None + self.access_tier = None + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.network_rule_set = None + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.enable_extended_groups = enable_extended_groups + self.is_hns_enabled = is_hns_enabled + self.geo_replication_stats = None + self.failover_in_progress = None + self.large_file_shares_state = large_file_shares_state + self.private_endpoint_connections = None + self.routing_preference = routing_preference + self.blob_restore_status = None + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.enable_nfs_v3 = enable_nfs_v3 + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.public_network_access = public_network_access + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.allowed_copy_scope = allowed_copy_scope + self.storage_account_sku_conversion_status = storage_account_sku_conversion_status + self.dns_endpoint_type = dns_endpoint_type + self.is_sku_conversion_blocked = None + self.account_migration_in_progress = None + + +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long + """The parameters used to check the availability of the storage account name. + + 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 name: The storage account name. Required. + :vartype name: str + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "name": {"required": True}, + "type": {"required": True, "constant": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + type = "Microsoft.Storage/storageAccounts" + + def __init__(self, *, name: str, **kwargs: Any) -> None: + """ + :keyword name: The storage account name. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters used when creating a storage account. + + All required parameters must be populated in order to send to server. + + :ivar sku: Required. Gets or sets the SKU name. Required. + :vartype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2023_05_01.models.Kind + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. + :vartype location: str + :ivar extended_location: Optional. Set the extended location of the resource. If not set, the + storage account will be created in Azure main region. Otherwise it will be created in the + specified extended location. + :vartype extended_location: ~azure.mgmt.storage.v2023_05_01.models.ExtendedLocation + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2023_05_01.models.Identity + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2023_05_01.models.AllowedCopyScope + :ivar public_network_access: Allow, disallow, or let Network Security Perimeter configuration + to evaluate public network access to Storage Account. Value is optional but if passed in, must + be 'Enabled', 'Disabled' or 'SecuredByPerimeter'. Known values are: "Enabled", "Disabled", and + "SecuredByPerimeter". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2023_05_01.models.PublicNetworkAccess + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2023_05_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2023_05_01.models.KeyPolicy + :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. + Only one custom domain is supported per storage account at this time. To clear the existing + custom domain, use an empty string for the custom domain name property. + :vartype custom_domain: ~azure.mgmt.storage.v2023_05_01.models.CustomDomain + :ivar encryption: Encryption settings to be used for server-side encryption for the storage + account. + :vartype encryption: ~azure.mgmt.storage.v2023_05_01.models.Encryption + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2023_05_01.models.NetworkRuleSet + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium", and "Cold". + :vartype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2023_05_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + The default value is true since API version 2019-04-01. + :vartype enable_https_traffic_only: bool + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar enable_extended_groups: Enables extended group support with local users feature, if set + to true. + :vartype enable_extended_groups: bool + :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :vartype is_hns_enabled: bool + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2023_05_01.models.LargeFileSharesState + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2023_05_01.models.RoutingPreference + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is false for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2", and "TLS1_3". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2023_05_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :vartype enable_nfs_v3: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + Set this property to true for new or existing accounts only if object replication policies will + involve storage accounts in different AAD tenants. The default interpretation is false for new + accounts to follow best security practices by default. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the new containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageAccount + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard" and "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2023_05_01.models.DnsEndpointType + """ + + _validation = { + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "enable_extended_groups": {"key": "properties.enableExtendedGroups", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + enable_extended_groups: Optional[bool] = None, + is_hns_enabled: Optional[bool] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + enable_nfs_v3: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: Required. Gets or sets the SKU name. Required. + :paramtype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". + :paramtype kind: str or ~azure.mgmt.storage.v2023_05_01.models.Kind + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. + :paramtype location: str + :keyword extended_location: Optional. Set the extended location of the resource. If not set, + the storage account will be created in Azure main region. Otherwise it will be created in the + specified extended location. + :paramtype extended_location: ~azure.mgmt.storage.v2023_05_01.models.ExtendedLocation + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2023_05_01.models.Identity + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2023_05_01.models.AllowedCopyScope + :keyword public_network_access: Allow, disallow, or let Network Security Perimeter + configuration to evaluate public network access to Storage Account. Value is optional but if + passed in, must be 'Enabled', 'Disabled' or 'SecuredByPerimeter'. Known values are: "Enabled", + "Disabled", and "SecuredByPerimeter". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2023_05_01.models.PublicNetworkAccess + :keyword sas_policy: SasPolicy assigned to the storage account. + :paramtype sas_policy: ~azure.mgmt.storage.v2023_05_01.models.SasPolicy + :keyword key_policy: KeyPolicy assigned to the storage account. + :paramtype key_policy: ~azure.mgmt.storage.v2023_05_01.models.KeyPolicy + :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. + Only one custom domain is supported per storage account at this time. To clear the existing + custom domain, use an empty string for the custom domain name property. + :paramtype custom_domain: ~azure.mgmt.storage.v2023_05_01.models.CustomDomain + :keyword encryption: Encryption settings to be used for server-side encryption for the storage + account. + :paramtype encryption: ~azure.mgmt.storage.v2023_05_01.models.Encryption + :keyword network_rule_set: Network rule set. + :paramtype network_rule_set: ~azure.mgmt.storage.v2023_05_01.models.NetworkRuleSet + :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier + is used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium", and "Cold". + :paramtype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.AccessTier + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2023_05_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. The default value is true since API version 2019-04-01. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword enable_extended_groups: Enables extended group support with local users feature, if + set to true. + :paramtype enable_extended_groups: bool + :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :paramtype is_hns_enabled: bool + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2023_05_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2023_05_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is false for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2", and "TLS1_3". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2023_05_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :paramtype enable_nfs_v3: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + Set this property to true for new or existing accounts only if object replication policies will + involve storage accounts in different AAD tenants. The default interpretation is false for new + accounts to follow best security practices by default. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the new containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageAccount + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard" and "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2023_05_01.models.DnsEndpointType + """ + super().__init__(**kwargs) + self.sku = sku + self.kind = kind + self.location = location + self.extended_location = extended_location + self.tags = tags + self.identity = identity + self.allowed_copy_scope = allowed_copy_scope + self.public_network_access = public_network_access + self.sas_policy = sas_policy + self.key_policy = key_policy + self.custom_domain = custom_domain + self.encryption = encryption + self.network_rule_set = network_rule_set + self.access_tier = access_tier + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.enable_extended_groups = enable_extended_groups + self.is_hns_enabled = is_hns_enabled + self.large_file_shares_state = large_file_shares_state + self.routing_preference = routing_preference + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.enable_nfs_v3 = enable_nfs_v3 + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.dns_endpoint_type = dns_endpoint_type + + +class StorageAccountInternetEndpoints(_serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a + internet routing endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + """ + + _validation = { + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, + } + + _attribute_map = { + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.blob = None + self.file = None + self.web = None + self.dfs = None + + +class StorageAccountKey(_serialization.Model): + """An access key for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_name: Name of the key. + :vartype key_name: str + :ivar value: Base 64-encoded value of the key. + :vartype value: str + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read" and "Full". + :vartype permissions: str or ~azure.mgmt.storage.v2023_05_01.models.KeyPermission + :ivar creation_time: Creation time of the key, in round trip date format. + :vartype creation_time: ~datetime.datetime + """ + + _validation = { + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.key_name = None + self.value = None + self.permissions = None + self.creation_time = None + + +class StorageAccountListKeysResult(_serialization.Model): + """The response from the ListKeys operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar keys: Gets the list of storage account keys and their properties for the specified + storage account. + :vartype keys: list[~azure.mgmt.storage.v2023_05_01.models.StorageAccountKey] + """ + + _validation = { + "keys": {"readonly": True}, + } + + _attribute_map = { + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.keys = None + + +class StorageAccountListResult(_serialization.Model): + """The response from the List Storage Accounts operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of storage accounts and their properties. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :ivar next_link: Request URL that can be used to query next page of storage accounts. Returned + when total number of requested storage accounts exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class StorageAccountMicrosoftEndpoints(_serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object + via a microsoft routing endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar queue: Gets the queue endpoint. + :vartype queue: str + :ivar table: Gets the table endpoint. + :vartype table: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + """ + + _validation = { + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, + } + + _attribute_map = { + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.blob = None + self.queue = None + self.table = None + self.file = None + self.web = None + self.dfs = None + + +class StorageAccountMigration(_serialization.Model): + """The parameters or status associated with an ongoing or enqueued storage account migration in + order to update its current SKU or region. + + 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 id: Migration Resource Id. + :vartype id: str + :ivar name: current value is 'default' for customer initiated migration. + :vartype name: str + :ivar type: SrpAccountMigrationType in ARM contract which is 'accountMigrations'. + :vartype type: str + :ivar target_sku_name: Target sku name for the account. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :vartype target_sku_name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + :ivar migration_status: Current status of migration. Known values are: "Invalid", + "SubmittedForConversion", "InProgress", "Complete", and "Failed". + :vartype migration_status: str or ~azure.mgmt.storage.v2023_05_01.models.MigrationStatus + :ivar migration_failed_reason: Error code for migration failure. + :vartype migration_failed_reason: str + :ivar migration_failed_detailed_reason: Reason for migration failure. + :vartype migration_failed_detailed_reason: str + """ + + _validation = { + "id": {"readonly": True}, + "target_sku_name": {"required": True}, + "migration_status": {"readonly": True}, + "migration_failed_reason": {"readonly": True}, + "migration_failed_detailed_reason": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "target_sku_name": {"key": "properties.targetSkuName", "type": "str"}, + "migration_status": {"key": "properties.migrationStatus", "type": "str"}, + "migration_failed_reason": {"key": "properties.migrationFailedReason", "type": "str"}, + "migration_failed_detailed_reason": {"key": "properties.migrationFailedDetailedReason", "type": "str"}, + } + + def __init__( + self, + *, + target_sku_name: Union[str, "_models.SkuName"], + name: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: current value is 'default' for customer initiated migration. + :paramtype name: str + :keyword type: SrpAccountMigrationType in ARM contract which is 'accountMigrations'. + :paramtype type: str + :keyword target_sku_name: Target sku name for the account. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :paramtype target_sku_name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + """ + super().__init__(**kwargs) + self.id = None + self.name = name + self.type = type + self.target_sku_name = target_sku_name + self.migration_status = None + self.migration_failed_reason = None + self.migration_failed_detailed_reason = None + + +class StorageAccountRegenerateKeyParameters(_serialization.Model): + """The parameters used to regenerate the storage account key. + + All required parameters must be populated in order to send to server. + + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. + :vartype key_name: str + """ + + _validation = { + "key_name": {"required": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, *, key_name: str, **kwargs: Any) -> None: + """ + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. + :paramtype key_name: str + """ + super().__init__(**kwargs) + self.key_name = key_name + + +class StorageAccountSkuConversionStatus(_serialization.Model): + """This defines the sku conversion status object for asynchronous sku conversions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar sku_conversion_status: This property indicates the current sku conversion status. Known + values are: "InProgress", "Succeeded", and "Failed". + :vartype sku_conversion_status: str or + ~azure.mgmt.storage.v2023_05_01.models.SkuConversionStatus + :ivar target_sku_name: This property represents the target sku name to which the account sku is + being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and + "Standard_RAGZRS". + :vartype target_sku_name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + :ivar start_time: This property represents the sku conversion start time. + :vartype start_time: str + :ivar end_time: This property represents the sku conversion end time. + :vartype end_time: str + """ + + _validation = { + "sku_conversion_status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + } + + _attribute_map = { + "sku_conversion_status": {"key": "skuConversionStatus", "type": "str"}, + "target_sku_name": {"key": "targetSkuName", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, + } + + def __init__(self, *, target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, **kwargs: Any) -> None: + """ + :keyword target_sku_name: This property represents the target sku name to which the account sku + is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and + "Standard_RAGZRS". + :paramtype target_sku_name: str or ~azure.mgmt.storage.v2023_05_01.models.SkuName + """ + super().__init__(**kwargs) + self.sku_conversion_status = None + self.target_sku_name = target_sku_name + self.start_time = None + self.end_time = None + + +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters that can be provided when updating the storage account properties. + + :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, + Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. + :vartype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2023_05_01.models.Identity + :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2023_05_01.models.Kind + :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the + CNAME source. Only one custom domain is supported per storage account at this time. To clear + the existing custom domain, use an empty string for the custom domain name property. + :vartype custom_domain: ~azure.mgmt.storage.v2023_05_01.models.CustomDomain + :ivar encryption: Not applicable. Azure Storage encryption at rest is enabled by default for + all storage accounts and cannot be disabled. + :vartype encryption: ~azure.mgmt.storage.v2023_05_01.models.Encryption + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2023_05_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2023_05_01.models.KeyPolicy + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium", and "Cold". + :vartype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2023_05_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + :vartype enable_https_traffic_only: bool + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar enable_extended_groups: Enables extended group support with local users feature, if set + to true. + :vartype enable_extended_groups: bool + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2023_05_01.models.NetworkRuleSet + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2023_05_01.models.LargeFileSharesState + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2023_05_01.models.RoutingPreference + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is false for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2", and "TLS1_3". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2023_05_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + Set this property to true for new or existing accounts only if object replication policies will + involve storage accounts in different AAD tenants. The default interpretation is false for new + accounts to follow best security practices by default. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar public_network_access: Allow, disallow, or let Network Security Perimeter configuration + to evaluate public network access to Storage Account. Value is optional but if passed in, must + be 'Enabled', 'Disabled' or 'SecuredByPerimeter'. Known values are: "Enabled", "Disabled", and + "SecuredByPerimeter". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2023_05_01.models.PublicNetworkAccess + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageAccount + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2023_05_01.models.AllowedCopyScope + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard" and "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2023_05_01.models.DnsEndpointType + """ + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "enable_extended_groups": {"key": "properties.enableExtendedGroups", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + enable_extended_groups: Optional[bool] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to + Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any + other value. + :paramtype sku: ~azure.mgmt.storage.v2023_05_01.models.Sku + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2023_05_01.models.Identity + :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + and "BlockBlobStorage". + :paramtype kind: str or ~azure.mgmt.storage.v2023_05_01.models.Kind + :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the + CNAME source. Only one custom domain is supported per storage account at this time. To clear + the existing custom domain, use an empty string for the custom domain name property. + :paramtype custom_domain: ~azure.mgmt.storage.v2023_05_01.models.CustomDomain + :keyword encryption: Not applicable. Azure Storage encryption at rest is enabled by default for + all storage accounts and cannot be disabled. + :paramtype encryption: ~azure.mgmt.storage.v2023_05_01.models.Encryption + :keyword sas_policy: SasPolicy assigned to the storage account. + :paramtype sas_policy: ~azure.mgmt.storage.v2023_05_01.models.SasPolicy + :keyword key_policy: KeyPolicy assigned to the storage account. + :paramtype key_policy: ~azure.mgmt.storage.v2023_05_01.models.KeyPolicy + :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier + is used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium", and "Cold". + :paramtype access_tier: str or ~azure.mgmt.storage.v2023_05_01.models.AccessTier + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2023_05_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword enable_extended_groups: Enables extended group support with local users feature, if + set to true. + :paramtype enable_extended_groups: bool + :keyword network_rule_set: Network rule set. + :paramtype network_rule_set: ~azure.mgmt.storage.v2023_05_01.models.NetworkRuleSet + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2023_05_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2023_05_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is false for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2", and "TLS1_3". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2023_05_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + Set this property to true for new or existing accounts only if object replication policies will + involve storage accounts in different AAD tenants. The default interpretation is false for new + accounts to follow best security practices by default. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword public_network_access: Allow, disallow, or let Network Security Perimeter + configuration to evaluate public network access to Storage Account. Value is optional but if + passed in, must be 'Enabled', 'Disabled' or 'SecuredByPerimeter'. Known values are: "Enabled", + "Disabled", and "SecuredByPerimeter". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2023_05_01.models.PublicNetworkAccess + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2023_05_01.models.ImmutableStorageAccount + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2023_05_01.models.AllowedCopyScope + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard" and "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2023_05_01.models.DnsEndpointType + """ + super().__init__(**kwargs) + self.sku = sku + self.tags = tags + self.identity = identity + self.kind = kind + self.custom_domain = custom_domain + self.encryption = encryption + self.sas_policy = sas_policy + self.key_policy = key_policy + self.access_tier = access_tier + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.enable_extended_groups = enable_extended_groups + self.network_rule_set = network_rule_set + self.large_file_shares_state = large_file_shares_state + self.routing_preference = routing_preference + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.public_network_access = public_network_access + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.allowed_copy_scope = allowed_copy_scope + self.dns_endpoint_type = dns_endpoint_type + + +class StorageQueue(Resource): + """StorageQueue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar metadata: A name-value pair that represents queue metadata. + :vartype metadata: dict[str, str] + :ivar approximate_message_count: Integer indicating an approximate number of messages in the + queue. This number is not lower than the actual number of messages in the queue, but could be + higher. + :vartype approximate_message_count: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, + } + + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword metadata: A name-value pair that represents queue metadata. + :paramtype metadata: dict[str, str] + """ + super().__init__(**kwargs) + self.metadata = metadata + self.approximate_message_count = None + + +class StorageSkuListResult(_serialization.Model): + """The response from the List Storage SKUs operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Get the list result of storage SKUs and their properties. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.SkuInformation] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SkuInformation]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + + +class StorageTaskAssignment(Resource): + """The storage task assignment. + + 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 id: Fully qualified resource ID for the resource. Ex - + /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 + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar properties: Properties of the storage task assignment. Required. + :vartype properties: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "StorageTaskAssignmentProperties"}, + } + + def __init__(self, *, properties: "_models.StorageTaskAssignmentProperties", **kwargs: Any) -> None: + """ + :keyword properties: Properties of the storage task assignment. Required. + :paramtype properties: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class StorageTaskAssignmentExecutionContext(_serialization.Model): + """Execution context of the storage task assignment. + + All required parameters must be populated in order to send to server. + + :ivar target: Execution target of the storage task assignment. + :vartype target: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTarget + :ivar trigger: Execution trigger of the storage task assignment. Required. + :vartype trigger: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTrigger + """ + + _validation = { + "trigger": {"required": True}, + } + + _attribute_map = { + "target": {"key": "target", "type": "ExecutionTarget"}, + "trigger": {"key": "trigger", "type": "ExecutionTrigger"}, + } + + def __init__( + self, *, trigger: "_models.ExecutionTrigger", target: Optional["_models.ExecutionTarget"] = None, **kwargs: Any + ) -> None: + """ + :keyword target: Execution target of the storage task assignment. + :paramtype target: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTarget + :keyword trigger: Execution trigger of the storage task assignment. Required. + :paramtype trigger: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTrigger + """ + super().__init__(**kwargs) + self.target = target + self.trigger = trigger + + +class StorageTaskAssignmentProperties(_serialization.Model): + """Properties of the storage task assignment. + + 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 task_id: Id of the corresponding storage task. Required. + :vartype task_id: str + :ivar enabled: Whether the storage task assignment is enabled or not. Required. + :vartype enabled: bool + :ivar description: Text that describes the purpose of the storage task assignment. Required. + :vartype description: str + :ivar execution_context: The storage task assignment execution context. Required. + :vartype execution_context: + ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentExecutionContext + :ivar report: The storage task assignment report. Required. + :vartype report: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentReport + :ivar provisioning_state: Represents the provisioning state of the storage task assignment. + Known values are: "Creating", "ResolvingDNS", "Succeeded", "ValidateSubscriptionQuotaBegin", + "ValidateSubscriptionQuotaEnd", "Deleting", "Canceled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.storage.v2023_05_01.models.ProvisioningState + :ivar run_status: Run status of storage task assignment. + :vartype run_status: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportProperties + """ + + _validation = { + "task_id": {"required": True}, + "enabled": {"required": True}, + "description": {"required": True}, + "execution_context": {"required": True}, + "report": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "task_id": {"key": "taskId", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "description": {"key": "description", "type": "str"}, + "execution_context": {"key": "executionContext", "type": "StorageTaskAssignmentExecutionContext"}, + "report": {"key": "report", "type": "StorageTaskAssignmentReport"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "run_status": {"key": "runStatus", "type": "StorageTaskReportProperties"}, + } + + def __init__( + self, + *, + task_id: str, + enabled: bool, + description: str, + execution_context: "_models.StorageTaskAssignmentExecutionContext", + report: "_models.StorageTaskAssignmentReport", + run_status: Optional["_models.StorageTaskReportProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword task_id: Id of the corresponding storage task. Required. + :paramtype task_id: str + :keyword enabled: Whether the storage task assignment is enabled or not. Required. + :paramtype enabled: bool + :keyword description: Text that describes the purpose of the storage task assignment. Required. + :paramtype description: str + :keyword execution_context: The storage task assignment execution context. Required. + :paramtype execution_context: + ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentExecutionContext + :keyword report: The storage task assignment report. Required. + :paramtype report: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentReport + :keyword run_status: Run status of storage task assignment. + :paramtype run_status: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportProperties + """ + super().__init__(**kwargs) + self.task_id = task_id + self.enabled = enabled + self.description = description + self.execution_context = execution_context + self.report = report + self.provisioning_state = None + self.run_status = run_status + + +class StorageTaskAssignmentReport(_serialization.Model): + """The storage task assignment report. + + All required parameters must be populated in order to send to server. + + :ivar prefix: The container prefix for the location of storage task assignment report. + Required. + :vartype prefix: str + """ + + _validation = { + "prefix": {"required": True}, + } + + _attribute_map = { + "prefix": {"key": "prefix", "type": "str"}, + } + + def __init__(self, *, prefix: str, **kwargs: Any) -> None: + """ + :keyword prefix: The container prefix for the location of storage task assignment report. + Required. + :paramtype prefix: str + """ + super().__init__(**kwargs) + self.prefix = prefix + + +class StorageTaskAssignmentsList(_serialization.Model): + """List of storage task assignments for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of storage task assignments and their properties. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :ivar next_link: Request URL that can be used to query next page of storage task assignments. + Returned when total number of requested storage task assignments exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StorageTaskAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class StorageTaskAssignmentUpdateExecutionContext(_serialization.Model): # pylint: disable=name-too-long + """Execution context of the storage task assignment update. + + :ivar target: Execution target of the storage task assignment. + :vartype target: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTarget + :ivar trigger: Execution trigger of the storage task assignment. + :vartype trigger: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTriggerUpdate + """ + + _attribute_map = { + "target": {"key": "target", "type": "ExecutionTarget"}, + "trigger": {"key": "trigger", "type": "ExecutionTriggerUpdate"}, + } + + def __init__( + self, + *, + target: Optional["_models.ExecutionTarget"] = None, + trigger: Optional["_models.ExecutionTriggerUpdate"] = None, + **kwargs: Any + ) -> None: + """ + :keyword target: Execution target of the storage task assignment. + :paramtype target: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTarget + :keyword trigger: Execution trigger of the storage task assignment. + :paramtype trigger: ~azure.mgmt.storage.v2023_05_01.models.ExecutionTriggerUpdate + """ + super().__init__(**kwargs) + self.target = target + self.trigger = trigger + + +class StorageTaskAssignmentUpdateParameters(_serialization.Model): + """Parameters of the storage task assignment update request. + + :ivar properties: Properties of the storage task assignment. + :vartype properties: + ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "StorageTaskAssignmentUpdateProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.StorageTaskAssignmentUpdateProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Properties of the storage task assignment. + :paramtype properties: + ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class StorageTaskAssignmentUpdateProperties(_serialization.Model): + """Properties of the storage task update assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar task_id: Id of the corresponding storage task. + :vartype task_id: str + :ivar enabled: Whether the storage task assignment is enabled or not. + :vartype enabled: bool + :ivar description: Text that describes the purpose of the storage task assignment. + :vartype description: str + :ivar execution_context: The storage task assignment execution context. + :vartype execution_context: + ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateExecutionContext + :ivar report: The storage task assignment report. + :vartype report: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateReport + :ivar provisioning_state: Represents the provisioning state of the storage task assignment. + Known values are: "Creating", "ResolvingDNS", "Succeeded", "ValidateSubscriptionQuotaBegin", + "ValidateSubscriptionQuotaEnd", "Deleting", "Canceled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.storage.v2023_05_01.models.ProvisioningState + :ivar run_status: Run status of storage task assignment. + :vartype run_status: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportProperties + """ + + _validation = { + "task_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "task_id": {"key": "taskId", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "description": {"key": "description", "type": "str"}, + "execution_context": {"key": "executionContext", "type": "StorageTaskAssignmentUpdateExecutionContext"}, + "report": {"key": "report", "type": "StorageTaskAssignmentUpdateReport"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "run_status": {"key": "runStatus", "type": "StorageTaskReportProperties"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + description: Optional[str] = None, + execution_context: Optional["_models.StorageTaskAssignmentUpdateExecutionContext"] = None, + report: Optional["_models.StorageTaskAssignmentUpdateReport"] = None, + run_status: Optional["_models.StorageTaskReportProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Whether the storage task assignment is enabled or not. + :paramtype enabled: bool + :keyword description: Text that describes the purpose of the storage task assignment. + :paramtype description: str + :keyword execution_context: The storage task assignment execution context. + :paramtype execution_context: + ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateExecutionContext + :keyword report: The storage task assignment report. + :paramtype report: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateReport + :keyword run_status: Run status of storage task assignment. + :paramtype run_status: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportProperties + """ + super().__init__(**kwargs) + self.task_id = None + self.enabled = enabled + self.description = description + self.execution_context = execution_context + self.report = report + self.provisioning_state = None + self.run_status = run_status + + +class StorageTaskAssignmentUpdateReport(_serialization.Model): + """The storage task assignment report. + + :ivar prefix: The prefix of the storage task assignment report. + :vartype prefix: str + """ + + _attribute_map = { + "prefix": {"key": "prefix", "type": "str"}, + } + + def __init__(self, *, prefix: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword prefix: The prefix of the storage task assignment report. + :paramtype prefix: str + """ + super().__init__(**kwargs) + self.prefix = prefix + + +class StorageTaskReportInstance(ProxyResource): + """Storage Tasks run report instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar properties: Storage task execution report for a run instance. + :vartype properties: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "StorageTaskReportProperties"}, + } + + def __init__(self, *, properties: Optional["_models.StorageTaskReportProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Storage task execution report for a run instance. + :paramtype properties: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class StorageTaskReportProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Storage task execution report for a run instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar task_assignment_id: Represents the Storage Task Assignment Id associated with the storage + task that provided an execution context. + :vartype task_assignment_id: str + :ivar storage_account_id: Represents the Storage Account Id where the storage task definition + was applied and executed. + :vartype storage_account_id: str + :ivar start_time: Start time of the run instance. Filter options such as startTime gt + '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for + DateTime properties in + https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. # pylint: disable=line-too-long + :vartype start_time: str + :ivar finish_time: End time of the run instance. Filter options such as startTime gt + '2023-06-26T20:51:24.4494016Z' and other comparison operators can be used as described for + DateTime properties in + https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. # pylint: disable=line-too-long + :vartype finish_time: str + :ivar objects_targeted_count: Total number of objects that meet the condition as defined in the + storage task assignment execution context. Filter options such as objectsTargetedCount gt 50 + and other comparison operators can be used as described for Numerical properties in + https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. # pylint: disable=line-too-long + :vartype objects_targeted_count: str + :ivar objects_operated_on_count: Total number of objects that meet the storage tasks condition + and were operated upon. Filter options such as objectsOperatedOnCount ge 100 and other + comparison operators can be used as described for Numerical properties in + https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. # pylint: disable=line-too-long + :vartype objects_operated_on_count: str + :ivar object_failed_count: Total number of objects where task operation failed when was + attempted. Filter options such as objectFailedCount eq 0 and other comparison operators can be + used as described for Numerical properties in + https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. # pylint: disable=line-too-long + :vartype object_failed_count: str + :ivar objects_succeeded_count: Total number of objects where task operation succeeded when was + attempted.Filter options such as objectsSucceededCount gt 150 and other comparison operators + can be used as described for Numerical properties in + https://learn.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities#supported-comparison-operators. # pylint: disable=line-too-long + :vartype objects_succeeded_count: str + :ivar run_status_error: Well known Azure Storage error code that represents the error + encountered during execution of the run instance. + :vartype run_status_error: str + :ivar run_status_enum: Represents the status of the execution. Known values are: "InProgress" + and "Finished". + :vartype run_status_enum: str or ~azure.mgmt.storage.v2023_05_01.models.RunStatusEnum + :ivar summary_report_path: Full path to the verbose report stored in the reporting container as + specified in the assignment execution context for the storage account. + :vartype summary_report_path: str + :ivar task_id: Storage Task Arm Id. + :vartype task_id: str + :ivar task_version: Storage Task Version. + :vartype task_version: str + :ivar run_result: Represents the overall result of the execution for the run instance. Known + values are: "Succeeded" and "Failed". + :vartype run_result: str or ~azure.mgmt.storage.v2023_05_01.models.RunResult + """ + + _validation = { + "task_assignment_id": {"readonly": True}, + "storage_account_id": {"readonly": True}, + "start_time": {"readonly": True}, + "finish_time": {"readonly": True}, + "objects_targeted_count": {"readonly": True}, + "objects_operated_on_count": {"readonly": True}, + "object_failed_count": {"readonly": True}, + "objects_succeeded_count": {"readonly": True}, + "run_status_error": {"readonly": True}, + "run_status_enum": {"readonly": True}, + "summary_report_path": {"readonly": True}, + "task_id": {"readonly": True}, + "task_version": {"readonly": True}, + "run_result": {"readonly": True}, + } + + _attribute_map = { + "task_assignment_id": {"key": "taskAssignmentId", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "finish_time": {"key": "finishTime", "type": "str"}, + "objects_targeted_count": {"key": "objectsTargetedCount", "type": "str"}, + "objects_operated_on_count": {"key": "objectsOperatedOnCount", "type": "str"}, + "object_failed_count": {"key": "objectFailedCount", "type": "str"}, + "objects_succeeded_count": {"key": "objectsSucceededCount", "type": "str"}, + "run_status_error": {"key": "runStatusError", "type": "str"}, + "run_status_enum": {"key": "runStatusEnum", "type": "str"}, + "summary_report_path": {"key": "summaryReportPath", "type": "str"}, + "task_id": {"key": "taskId", "type": "str"}, + "task_version": {"key": "taskVersion", "type": "str"}, + "run_result": {"key": "runResult", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.task_assignment_id = None + self.storage_account_id = None + self.start_time = None + self.finish_time = None + self.objects_targeted_count = None + self.objects_operated_on_count = None + self.object_failed_count = None + self.objects_succeeded_count = None + self.run_status_error = None + self.run_status_enum = None + self.summary_report_path = None + self.task_id = None + self.task_version = None + self.run_result = None + + +class StorageTaskReportSummary(_serialization.Model): + """Fetch Storage Tasks Run Summary. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets storage tasks run result summary. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportInstance] + :ivar next_link: Request URL that can be used to query next page of storage task run results + summary. Returned when the number of run instances and summary reports exceed maximum page + size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StorageTaskReportInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.storage.v2023_05_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2023_05_01.models.CreatedByType + :ivar last_modified_at: The timestamp of 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.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.storage.v2023_05_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2023_05_01.models.CreatedByType + :keyword last_modified_at: The timestamp of 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 Table(Resource): + """Properties of the table, including Id, resource name, resource type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar table_name: Table name under the specified account. + :vartype table_name: str + :ivar signed_identifiers: List of stored access policies specified on the table. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2023_05_01.models.TableSignedIdentifier] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[TableSignedIdentifier]"}, + } + + def __init__( + self, *, signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, **kwargs: Any + ) -> None: + """ + :keyword signed_identifiers: List of stored access policies specified on the table. + :paramtype signed_identifiers: + list[~azure.mgmt.storage.v2023_05_01.models.TableSignedIdentifier] + """ + super().__init__(**kwargs) + self.table_name = None + self.signed_identifiers = signed_identifiers + + +class TableAccessPolicy(_serialization.Model): + """Table Access Policy Properties Object. + + All required parameters must be populated in order to send to server. + + :ivar start_time: Start time of the access policy. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Expiry time of the access policy. + :vartype expiry_time: ~datetime.datetime + :ivar permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. + :vartype permission: str + """ + + _validation = { + "permission": {"required": True}, + } + + _attribute_map = { + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, + } + + def __init__( + self, + *, + permission: str, + start_time: Optional[datetime.datetime] = None, + expiry_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_time: Start time of the access policy. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Expiry time of the access policy. + :paramtype expiry_time: ~datetime.datetime + :keyword permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. + :paramtype permission: str + """ + super().__init__(**kwargs) + self.start_time = start_time + self.expiry_time = expiry_time + self.permission = permission + + +class TableServiceProperties(Resource): + """The properties of a storage account’s Table service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar cors: Specifies CORS rules for the Table service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Table service. + :vartype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + } + + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs: Any) -> None: + """ + :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Table service. + :paramtype cors: ~azure.mgmt.storage.v2023_05_01.models.CorsRules + """ + super().__init__(**kwargs) + self.cors = cors + + +class TableSignedIdentifier(_serialization.Model): + """Object to set Table Access Policy. + + All required parameters must be populated in order to send to server. + + :ivar id: unique-64-character-value of the stored access policy. Required. + :vartype id: str + :ivar access_policy: Access policy. + :vartype access_policy: ~azure.mgmt.storage.v2023_05_01.models.TableAccessPolicy + """ + + _validation = { + "id": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "TableAccessPolicy"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + access_policy: Optional["_models.TableAccessPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: unique-64-character-value of the stored access policy. Required. + :paramtype id: str + :keyword access_policy: Access policy. + :paramtype access_policy: ~azure.mgmt.storage.v2023_05_01.models.TableAccessPolicy + """ + super().__init__(**kwargs) + self.id = id + self.access_policy = access_policy + + +class TagFilter(_serialization.Model): + """Blob index tag based filtering for blob objects. + + All required parameters must be populated in order to send to server. + + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. + :vartype name: str + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. + :vartype op: str + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. + :vartype value: str + """ + + _validation = { + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, op: str, value: str, **kwargs: Any) -> None: + """ + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. + :paramtype name: str + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. + :paramtype op: str + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.op = op + self.value = value + + +class TagProperty(_serialization.Model): + """A tag of the LegalHold of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tag: The tag value. + :vartype tag: str + :ivar timestamp: Returns the date and time the tag was added. + :vartype timestamp: ~datetime.datetime + :ivar object_identifier: Returns the Object ID of the user who added the tag. + :vartype object_identifier: str + :ivar tenant_id: Returns the Tenant ID that issued the token for the user who added the tag. + :vartype tenant_id: str + :ivar upn: Returns the User Principal Name of the user who added the tag. + :vartype upn: str + """ + + _validation = { + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, + } + + _attribute_map = { + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.tag = None + self.timestamp = None + self.object_identifier = None + self.tenant_id = None + self.upn = None + + +class TriggerParameters(_serialization.Model): + """The trigger parameters update for the storage task assignment execution. + + :ivar start_from: When to start task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :vartype start_from: ~datetime.datetime + :ivar interval: Run interval of task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :vartype interval: int + :ivar interval_unit: Run interval unit of task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. Default value is "Days". + :vartype interval_unit: str + :ivar end_by: When to end task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :vartype end_by: ~datetime.datetime + :ivar start_on: When to start task execution. This is an optional field when + ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when + ExecutionTrigger.properties.type is 'OnSchedule'. + :vartype start_on: ~datetime.datetime + """ + + _validation = { + "interval": {"minimum": 1}, + } + + _attribute_map = { + "start_from": {"key": "startFrom", "type": "iso-8601"}, + "interval": {"key": "interval", "type": "int"}, + "interval_unit": {"key": "intervalUnit", "type": "str"}, + "end_by": {"key": "endBy", "type": "iso-8601"}, + "start_on": {"key": "startOn", "type": "iso-8601"}, + } + + def __init__( + self, + *, + start_from: Optional[datetime.datetime] = None, + interval: Optional[int] = None, + interval_unit: Optional[Literal["Days"]] = None, + end_by: Optional[datetime.datetime] = None, + start_on: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_from: When to start task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :paramtype start_from: ~datetime.datetime + :keyword interval: Run interval of task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :paramtype interval: int + :keyword interval_unit: Run interval unit of task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. Default value is "Days". + :paramtype interval_unit: str + :keyword end_by: When to end task execution. This is a required field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :paramtype end_by: ~datetime.datetime + :keyword start_on: When to start task execution. This is an optional field when + ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when + ExecutionTrigger.properties.type is 'OnSchedule'. + :paramtype start_on: ~datetime.datetime + """ + super().__init__(**kwargs) + self.start_from = start_from + self.interval = interval + self.interval_unit = interval_unit + self.end_by = end_by + self.start_on = start_on + + +class TriggerParametersUpdate(_serialization.Model): + """The trigger parameters update for the storage task assignment execution. + + :ivar start_from: When to start task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :vartype start_from: ~datetime.datetime + :ivar interval: Run interval of task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :vartype interval: int + :ivar interval_unit: Run interval unit of task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. Default value is "Days". + :vartype interval_unit: str + :ivar end_by: When to end task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :vartype end_by: ~datetime.datetime + :ivar start_on: When to start task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when + ExecutionTrigger.properties.type is 'OnSchedule'. + :vartype start_on: ~datetime.datetime + """ + + _validation = { + "interval": {"minimum": 1}, + } + + _attribute_map = { + "start_from": {"key": "startFrom", "type": "iso-8601"}, + "interval": {"key": "interval", "type": "int"}, + "interval_unit": {"key": "intervalUnit", "type": "str"}, + "end_by": {"key": "endBy", "type": "iso-8601"}, + "start_on": {"key": "startOn", "type": "iso-8601"}, + } + + def __init__( + self, + *, + start_from: Optional[datetime.datetime] = None, + interval: Optional[int] = None, + interval_unit: Optional[Literal["Days"]] = None, + end_by: Optional[datetime.datetime] = None, + start_on: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_from: When to start task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :paramtype start_from: ~datetime.datetime + :keyword interval: Run interval of task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :paramtype interval: int + :keyword interval_unit: Run interval unit of task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. Default value is "Days". + :paramtype interval_unit: str + :keyword end_by: When to end task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when + ExecutionTrigger.properties.type is 'RunOnce'. + :paramtype end_by: ~datetime.datetime + :keyword start_on: When to start task execution. This is a mutable field when + ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when + ExecutionTrigger.properties.type is 'OnSchedule'. + :paramtype start_on: ~datetime.datetime + """ + super().__init__(**kwargs) + self.start_from = start_from + self.interval = interval + self.interval_unit = interval_unit + self.end_by = end_by + self.start_on = start_on + + +class UpdateHistoryProperty(_serialization.Model): + """An update history of the ImmutabilityPolicy of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: + put, lock and extend. Known values are: "put", "lock", and "extend". + :vartype update: str or ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicyUpdateType + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar timestamp: Returns the date and time the ImmutabilityPolicy was updated. + :vartype timestamp: ~datetime.datetime + :ivar object_identifier: Returns the Object ID of the user who updated the ImmutabilityPolicy. + :vartype object_identifier: str + :ivar tenant_id: Returns the Tenant ID that issued the token for the user who updated the + ImmutabilityPolicy. + :vartype tenant_id: str + :ivar upn: Returns the User Principal Name of the user who updated the ImmutabilityPolicy. + :vartype upn: str + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, + } + + _attribute_map = { + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, + *, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.update = None + self.immutability_period_since_creation_in_days = None + self.timestamp = None + self.object_identifier = None + self.tenant_id = None + self.upn = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class Usage(_serialization.Model): + """Describes Storage Resource Usage. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", + "Percent", "CountsPerSecond", and "BytesPerSecond". + :vartype unit: str or ~azure.mgmt.storage.v2023_05_01.models.UsageUnit + :ivar current_value: Gets the current count of the allocated resources in the subscription. + :vartype current_value: int + :ivar limit: Gets the maximum count of the resources that can be allocated in the subscription. + :vartype limit: int + :ivar name: Gets the name of the type of usage. + :vartype name: ~azure.mgmt.storage.v2023_05_01.models.UsageName + """ + + _validation = { + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, + } + + _attribute_map = { + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.unit = None + self.current_value = None + self.limit = None + self.name = None + + +class UsageListResult(_serialization.Model): + """The response from the List Usages operation. + + :ivar value: Gets or sets the list of Storage Resource Usages. + :vartype value: list[~azure.mgmt.storage.v2023_05_01.models.Usage] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Usage]"}, + } + + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Gets or sets the list of Storage Resource Usages. + :paramtype value: list[~azure.mgmt.storage.v2023_05_01.models.Usage] + """ + super().__init__(**kwargs) + self.value = value + + +class UsageName(_serialization.Model): + """The usage names that can be used; currently limited to StorageAccount. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets a string describing the resource name. + :vartype value: str + :ivar localized_value: Gets a localized string describing the resource name. + :vartype localized_value: str + """ + + _validation = { + "value": {"readonly": True}, + "localized_value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.localized_value = None + + +class UserAssignedIdentity(_serialization.Model): + """UserAssignedIdentity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the identity. + :vartype principal_id: str + :ivar client_id: The client ID of the identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class VirtualNetworkRule(_serialization.Model): + """Virtual Network rule. + + All required parameters must be populated in order to send to server. + + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long + Required. + :vartype virtual_network_resource_id: str + :ivar action: The action of virtual network rule. Default value is "Allow". + :vartype action: str + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". + :vartype state: str or ~azure.mgmt.storage.v2023_05_01.models.State + """ + + _validation = { + "virtual_network_resource_id": {"required": True}, + } + + _attribute_map = { + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__( + self, + *, + virtual_network_resource_id: str, + action: Optional[Literal["Allow"]] = None, + state: Optional[Union[str, "_models.State"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long + Required. + :paramtype virtual_network_resource_id: str + :keyword action: The action of virtual network rule. Default value is "Allow". + :paramtype action: str + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". + :paramtype state: str or ~azure.mgmt.storage.v2023_05_01.models.State + """ + super().__init__(**kwargs) + self.virtual_network_resource_id = virtual_network_resource_id + self.action = action + self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_storage_management_client_enums.py new file mode 100644 index 000000000000..2f2880a5b917 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/models/_storage_management_client_enums.py @@ -0,0 +1,706 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Required for storage accounts where kind = BlobStorage. The access tier is used for billing. + The 'Premium' access tier is the default value for premium block blobs storage account type and + it cannot be changed for the premium block blobs storage account type. + """ + + HOT = "Hot" + COOL = "Cool" + PREMIUM = "Premium" + COLD = "Cold" + + +class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the + policy, Unlocked state allows increase and decrease of immutability retention time and also + allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of + the immutability retention time. A policy can only be created in a Disabled or Unlocked state + and can be toggled between the two states. Only a policy in an Unlocked state can transition to + a Locked state which cannot be reverted. + """ + + UNLOCKED = "Unlocked" + LOCKED = "Locked" + DISABLED = "Disabled" + + +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status indicating whether the primary location of the storage account is available or + unavailable. + """ + + AVAILABLE = "available" + UNAVAILABLE = "unavailable" + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the Active Directory account type for Azure Storage.""" + + USER = "User" + COMPUTER = "Computer" + + +class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the + same VNet. + """ + + PRIVATE_LINK = "PrivateLink" + AAD = "AAD" + + +class AllowedMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AllowedMethods.""" + + DELETE = "DELETE" + GET = "GET" + HEAD = "HEAD" + MERGE = "MERGE" + POST = "POST" + OPTIONS = "OPTIONS" + PUT = "PUT" + PATCH = "PATCH" + CONNECT = "CONNECT" + TRACE = "TRACE" + + +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" + + DEFAULT = "default" + + +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob + restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - + Failed: Indicates that blob restore is failed. + """ + + IN_PROGRESS = "InProgress" + COMPLETE = "Complete" + FAILED = "Failed" + + +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are + any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to + bypass none of those traffics. + """ + + NONE = "None" + LOGGING = "Logging" + METRICS = "Metrics" + AZURE_SERVICES = "AzureServices" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the default action of allow or deny when no other rules match.""" + + ALLOW = "Allow" + DENY = "Deny" + + +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" + + NONE = "None" + STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" + STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" + STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + + +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the directory service used. Note that this enum may be extended in the future.""" + + NONE = "None" + AADDS = "AADDS" + AD = "AD" + AADKERB = "AADKERB" + + +class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number + of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the + endpoint URL will have an alphanumeric DNS Zone identifier. + """ + + STANDARD = "Standard" + AZURE_DNS_ZONE = "AzureDnsZone" + + +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication protocol that is used for the file share. Can only be specified when + creating a share. + """ + + SMB = "SMB" + NFS = "NFS" + + +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, + Microsoft.KeyVault. + """ + + MICROSOFT_STORAGE = "Microsoft.Storage" + MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + + +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SAS Expiration Action defines the action to be performed when sasPolicy.sasExpirationPeriod + is violated. The 'Log' action can be used for audit purposes and the 'Block' action can be used + to block and deny the usage of SAS tokens that do not adhere to the sas policy expiration + period. + """ + + LOG = "Log" + BLOCK = "Block" + + +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of extendedLocation.""" + + EDGE_ZONE = "EdgeZone" + + +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field, it specifies the format for the inventory files.""" + + CSV = "Csv" + PARQUET = "Parquet" + + +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the secondary location. Possible values are: - Live: Indicates that the secondary + location is active and operational. - Bootstrap: Indicates initial synchronization from the + primary location to the secondary location is in progress.This typically occurs when + replication is first enabled. - Unavailable: Indicates that the secondary location is + temporarily unavailable. + """ + + LIVE = "Live" + BOOTSTRAP = "Bootstrap" + UNAVAILABLE = "Unavailable" + + +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The protocol permitted for a request made with the account SAS.""" + + HTTPS_HTTP = "https,http" + HTTPS = "https" + + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" + + LOCKED = "Locked" + UNLOCKED = "Unlocked" + + +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and + extend. + """ + + PUT = "put" + LOCK = "lock" + EXTEND = "extend" + + +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The valid value is Inventory.""" + + INVENTORY = "Inventory" + + +class IssueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of issue.""" + + UNKNOWN = "Unknown" + CONFIGURATION_PROPAGATION_FAILURE = "ConfigurationPropagationFailure" + + +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Permissions for the key -- read-only or full permissions.""" + + READ = "Read" + FULL = "Full" + + +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, + Microsoft.Keyvault. + """ + + MICROSOFT_STORAGE = "Microsoft.Storage" + MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + + +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encryption key type to be used for the encryption service. 'Account' key type implies that an + account-scoped encryption key will be used. 'Service' key type implies that a default service + key is used. + """ + + SERVICE = "Service" + ACCOUNT = "Account" + + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the type of storage account.""" + + STORAGE = "Storage" + STORAGE_V2 = "StorageV2" + BLOB_STORAGE = "BlobStorage" + FILE_STORAGE = "FileStorage" + BLOCK_BLOB_STORAGE = "BlockBlobStorage" + + +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the lease action. Can be one of the available actions.""" + + ACQUIRE = "Acquire" + RENEW = "Renew" + CHANGE = "Change" + RELEASE = "Release" + BREAK_ENUM = "Break" + + +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether the lease on a container is of infinite or fixed duration, only when the + container is leased. + """ + + INFINITE = "Infinite" + FIXED = "Fixed" + + +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the lease action. Can be one of the available actions.""" + + ACQUIRE = "Acquire" + RENEW = "Renew" + CHANGE = "Change" + RELEASE = "Release" + BREAK_ENUM = "Break" + + +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Lease state of the container.""" + + AVAILABLE = "Available" + LEASED = "Leased" + EXPIRED = "Expired" + BREAKING = "Breaking" + BROKEN = "Broken" + + +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lease status of the container.""" + + LOCKED = "Locked" + UNLOCKED = "Unlocked" + + +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" + + DELETED = "deleted" + + +class ListEncryptionScopesInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListEncryptionScopesInclude.""" + + ALL = "All" + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ListLocalUserIncludeParam(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListLocalUserIncludeParam.""" + + NFSV3 = "nfsv3" + + +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" + + DEFAULT = "default" + + +class MigrationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationName.""" + + DEFAULT = "default" + + +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property denotes the container level immutability to object level immutability migration + state. + """ + + IN_PROGRESS = "InProgress" + COMPLETED = "Completed" + + +class MigrationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of migration.""" + + INVALID = "Invalid" + SUBMITTED_FOR_CONVERSION = "SubmittedForConversion" + IN_PROGRESS = "InProgress" + COMPLETE = "Complete" + FAILED = "Failed" + + +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Set the minimum TLS version to be permitted on requests to storage. The default interpretation + is TLS 1.0 for this property. + """ + + TLS1_0 = "TLS1_0" + TLS1_1 = "TLS1_1" + TLS1_2 = "TLS1_2" + TLS1_3 = "TLS1_3" + + +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" + + ACCESS_TIME_TRACKING = "AccessTimeTracking" + + +class NetworkSecurityPerimeterConfigurationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of Network Security Perimeter configuration propagation.""" + + ACCEPTED = "Accepted" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + DELETING = "Deleting" + CANCELED = "Canceled" + + +class NspAccessRuleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Direction of Access Rule.""" + + INBOUND = "Inbound" + OUTBOUND = "Outbound" + + +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field. This field specifies the scope of the inventory created either at the + blob or container level. + """ + + BLOB = "Blob" + CONTAINER = "Container" + + +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), + Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + """ + + R = "r" + D = "d" + W = "w" + L = "l" + A = "a" + C = "c" + U = "u" + P = "p" + + +class PostFailoverRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The redundancy type of the account after an account failover is performed.""" + + STANDARD_LRS = "Standard_LRS" + STANDARD_ZRS = "Standard_ZRS" + + +class PostPlannedFailoverRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The redundancy type of the account after a planned account failover is performed.""" + + STANDARD_GRS = "Standard_GRS" + STANDARD_GZRS = "Standard_GZRS" + STANDARD_RAGRS = "Standard_RAGRS" + STANDARD_RAGZRS = "Standard_RAGZRS" + + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the storage account at the time the operation was called.""" + + CREATING = "Creating" + RESOLVING_DNS = "ResolvingDNS" + SUCCEEDED = "Succeeded" + VALIDATE_SUBSCRIPTION_QUOTA_BEGIN = "ValidateSubscriptionQuotaBegin" + VALIDATE_SUBSCRIPTION_QUOTA_END = "ValidateSubscriptionQuotaEnd" + DELETING = "Deleting" + CANCELED = "Canceled" + FAILED = "Failed" + + +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether data in the container may be accessed publicly and the level of access.""" + + CONTAINER = "Container" + BLOB = "Blob" + NONE = "None" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow, disallow, or let Network Security Perimeter configuration to evaluate public network + access to Storage Account. Value is optional but if passed in, must be 'Enabled', 'Disabled' or + 'SecuredByPerimeter'. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + SECURED_BY_PERIMETER = "SecuredByPerimeter" + + +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the reason that a storage account name could not be used. The Reason element is only + returned if NameAvailable is false. + """ + + ACCOUNT_NAME_INVALID = "AccountNameInvalid" + ALREADY_EXISTS = "AlreadyExists" + + +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. + """ + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + + +class ResourceAssociationAccessMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access Mode of the resource association.""" + + ENFORCED = "Enforced" + LEARNING = "Learning" + AUDIT = "Audit" + + +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The property is for NFS share only. The default is NoRootSquash.""" + + NO_ROOT_SQUASH = "NoRootSquash" + ROOT_SQUASH = "RootSquash" + ALL_SQUASH = "AllSquash" + + +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Routing Choice defines the kind of network routing opted by the user.""" + + MICROSOFT_ROUTING = "MicrosoftRouting" + INTERNET_ROUTING = "InternetRouting" + + +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The valid value is Lifecycle.""" + + LIFECYCLE = "Lifecycle" + + +class RunResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the overall result of the execution for the run instance.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class RunStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the status of the execution.""" + + IN_PROGRESS = "InProgress" + FINISHED = "Finished" + + +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field. This field is used to schedule an inventory formation.""" + + DAILY = "Daily" + WEEKLY = "Weekly" + + +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue + (q), Table (t), File (f). + """ + + B = "b" + Q = "q" + T = "t" + F = "f" + + +class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the issue.""" + + WARNING = "Warning" + ERROR = "Error" + + +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), + Hot, and Cool. FileStorage account can choose Premium. + """ + + TRANSACTION_OPTIMIZED = "TransactionOptimized" + HOT = "Hot" + COOL = "Cool" + PREMIUM = "Premium" + + +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed services accessible with the service SAS. Possible values include: Blob (b), + Container (c), File (f), Share (s). + """ + + B = "b" + C = "c" + F = "f" + S = "s" + + +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed resource types that are accessible with the account SAS. Service (s): Access to + service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to + object-level APIs for blobs, queue messages, table entities, and files. + """ + + S = "s" + C = "c" + O = "o" + + +class SkuConversionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property indicates the current sku conversion status.""" + + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name. Required for account creation; optional for update. Note that in older versions, + SKU name was called accountType. + """ + + STANDARD_LRS = "Standard_LRS" + STANDARD_GRS = "Standard_GRS" + STANDARD_RAGRS = "Standard_RAGRS" + STANDARD_ZRS = "Standard_ZRS" + PREMIUM_LRS = "Premium_LRS" + PREMIUM_ZRS = "Premium_ZRS" + STANDARD_GZRS = "Standard_GZRS" + STANDARD_RAGZRS = "Standard_RAGZRS" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier. This is based on the SKU name.""" + + STANDARD = "Standard" + PREMIUM = "Premium" + + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the state of virtual network rule.""" + + PROVISIONING = "Provisioning" + DEPROVISIONING = "Deprovisioning" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + + +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" + + GEO_REPLICATION_STATS = "geoReplicationStats" + BLOB_RESTORE_STATUS = "blobRestoreStatus" + + +class TriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The trigger type of the storage task assignment execution.""" + + RUN_ONCE = "RunOnce" + ON_SCHEDULE = "OnSchedule" + + +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the unit of measurement.""" + + COUNT = "Count" + BYTES = "Bytes" + SECONDS = "Seconds" + PERCENT = "Percent" + COUNTS_PER_SECOND = "CountsPerSecond" + BYTES_PER_SECOND = "BytesPerSecond" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/__init__.py new file mode 100644 index 000000000000..e62e153ac4a1 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/__init__.py @@ -0,0 +1,65 @@ +# 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 ._blob_services_operations import BlobServicesOperations +from ._blob_containers_operations import BlobContainersOperations +from ._file_services_operations import FileServicesOperations +from ._file_shares_operations import FileSharesOperations +from ._queue_services_operations import QueueServicesOperations +from ._queue_operations import QueueOperations +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._deleted_accounts_operations import DeletedAccountsOperations +from ._usages_operations import UsagesOperations +from ._management_policies_operations import ManagementPoliciesOperations +from ._blob_inventory_policies_operations import BlobInventoryPoliciesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._object_replication_policies_operations import ObjectReplicationPoliciesOperations +from ._local_users_operations import LocalUsersOperations +from ._encryption_scopes_operations import EncryptionScopesOperations +from ._table_services_operations import TableServicesOperations +from ._table_operations import TableOperations +from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations +from ._storage_task_assignments_operations import StorageTaskAssignmentsOperations +from ._storage_task_assignments_instances_report_operations import StorageTaskAssignmentsInstancesReportOperations +from ._storage_task_assignment_instances_report_operations import StorageTaskAssignmentInstancesReportOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "TableServicesOperations", + "TableOperations", + "NetworkSecurityPerimeterConfigurationsOperations", + "StorageTaskAssignmentsOperations", + "StorageTaskAssignmentsInstancesReportOperations", + "StorageTaskAssignmentInstancesReportOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_containers_operations.py new file mode 100644 index 000000000000..d32a67793c77 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_containers_operations.py @@ -0,0 +1,2398 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_set_legal_hold_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_clear_legal_hold_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_create_or_update_immutability_policy_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_lock_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extend_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + 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_lease_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_object_level_worm_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`blob_containers` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, + **kwargs: Any + ) -> Iterable["_models.ListContainerItem"]: + """Lists all containers and does not support a prefix like data plane. Also SRP today does not + return continuation token. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of containers that can be included in + the list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only container names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, used to include the properties for soft deleted blob containers. + "deleted" Default value is None. + :type include: str or ~azure.mgmt.storage.v2023_05_01.models.ListContainersInclude + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListContainerItems] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListContainerItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: 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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO[bytes]], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a BlobContainer + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer or IO[bytes] + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IOBase, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: 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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO[bytes]], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a BlobContainer + type or a IO[bytes] type. Required. + :type blob_container: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer or IO[bytes] + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IOBase, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> _models.BlobContainer: + """Gets properties of a specified container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobContainer + :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._api_version or "2023-05-01")) + cls: ClsType[_models.BlobContainer] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + """Deletes specified container under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: 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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO[bytes]], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold or IO[bytes] + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LegalHold] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IOBase, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + _request = build_set_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: 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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO[bytes]], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + LegalHold type or a IO[bytes] type. Required. + :type legal_hold: ~azure.mgmt.storage.v2023_05_01.models.LegalHold or IO[bytes] + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LegalHold + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LegalHold] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IOBase, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + _request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy or IO[bytes] + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + _request = build_create_or_update_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Gets the existing immutability policy along with the corresponding ETag in response headers and + body. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + _request = build_get_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Aborts an unlocked immutability policy. The response of delete has + immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this + operation. Deleting a locked immutability policy is not allowed, the only way is to delete the + container after deleting all expired blobs inside the policy locked container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name: Literal["default"] = kwargs.pop("immutability_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + _request = build_delete_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def lock_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is + ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + _request = build_lock_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a ImmutabilityPolicy type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy or IO[bytes] + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ImmutabilityPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ImmutabilityPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + _request = build_extend_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a LeaseContainerRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerRequest or IO[bytes] + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseContainerResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LeaseContainerResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None + + _request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_object_level_worm_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> LROPoller[None]: + """This operation migrates a blob container from container level WORM to object level immutability + enabled container. Prerequisites require a container level immutability policy either in locked + or unlocked state, Account level versioning must be enabled and there should be no Legal hold + on the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._object_level_worm_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_inventory_policies_operations.py new file mode 100644 index 000000000000..9f6143916daa --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_inventory_policies_operations.py @@ -0,0 +1,595 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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 BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a + BlobInventoryPolicy type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy or IO[bytes] + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobInventoryPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> None: + """Deletes the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicyName + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListBlobInventoryPolicy] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListBlobInventoryPolicy", 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) + + _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/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_services_operations.py new file mode 100644 index 000000000000..ffd1e667b709 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_blob_services_operations.py @@ -0,0 +1,470 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_set_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") + 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.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`blob_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: + """List blob services of storage account. It returns a collection of one object named default. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.BlobServiceItems] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BlobServiceItems", 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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a + BlobServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties or IO[bytes] + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :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 = 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._api_version or "2023-05-01")) + blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.BlobServiceProperties: + """Gets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.BlobServiceProperties + :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._api_version or "2023-05-01")) + blob_services_name: Literal["default"] = kwargs.pop("blob_services_name", "default") + cls: ClsType[_models.BlobServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_deleted_accounts_operations.py new file mode 100644 index 000000000000..398456eab3ca --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_deleted_accounts_operations.py @@ -0,0 +1,250 @@ +# 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, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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 DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`deleted_accounts` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: + """Lists deleted accounts under the subscription. + + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.DeletedAccountListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedAccountListResult", 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) + + @distributed_trace + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: + """Get properties of specified deleted account resource. + + :param deleted_account_name: Name of the deleted storage account. Required. + :type deleted_account_name: str + :param location: The location of the deleted storage account. Required. + :type location: str + :return: DeletedAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.DeletedAccount + :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._api_version or "2023-05-01")) + cls: ClsType[_models.DeletedAccount] = kwargs.pop("cls", None) + + _request = build_get_request( + deleted_account_name=deleted_account_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_encryption_scopes_operations.py new file mode 100644 index 000000000000..b61140c015fa --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_encryption_scopes_operations.py @@ -0,0 +1,732 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_put_request( + resource_group_name: str, account_name: str, encryption_scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_patch_request( + resource_group_name: str, account_name: str, encryption_scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, encryption_scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListEncryptionScopesInclude]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "int", maximum=5000, minimum=1) + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`encryption_scopes` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: 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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope or IO[bytes] + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IOBase, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + _request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: 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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO[bytes]], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + EncryptionScope type or a IO[bytes] type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope or IO[bytes] + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IOBase, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + _request = build_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> _models.EncryptionScope: + """Returns the properties for the specified encryption scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.EncryptionScope + :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._api_version or "2023-05-01")) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListEncryptionScopesInclude]] = None, + **kwargs: Any + ) -> Iterable["_models.EncryptionScope"]: + """Lists all the encryption scopes available under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of encryption scopes that will be + included in the list response. Default value is None. + :type maxpagesize: int + :param filter: Optional. When specified, only encryption scope names starting with the filter + will be listed. Default value is None. + :type filter: str + :param include: Optional, when specified, will list encryption scopes with the specific state. + Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. + :type include: str or ~azure.mgmt.storage.v2023_05_01.models.ListEncryptionScopesInclude + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.EncryptionScopeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EncryptionScopeListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_file_services_operations.py new file mode 100644 index 000000000000..09a9851186bd --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_file_services_operations.py @@ -0,0 +1,437 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_set_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") + 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.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`file_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: + """List all file services in storage accounts. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: FileServiceItems or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceItems + :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._api_version or "2023-05-01")) + cls: ClsType[_models.FileServiceItems] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceItems", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a FileServiceProperties type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties or IO[bytes] + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :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 = 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._api_version or "2023-05-01")) + file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.FileServiceProperties: + """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileServiceProperties + :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._api_version or "2023-05-01")) + file_services_name: Literal["default"] = kwargs.pop("file_services_name", "default") + cls: ClsType[_models.FileServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_file_shares_operations.py new file mode 100644 index 000000000000..d042bee52013 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_file_shares_operations.py @@ -0,0 +1,1310 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, share_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + if x_ms_snapshot is not None: + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + if x_ms_snapshot is not None: + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_request( + resource_group_name: str, account_name: str, share_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_lease_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if x_ms_snapshot is not None: + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + 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 FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`file_shares` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.FileShareItem"]: + """Lists all shares. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of shares that can be included in the + list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only share names starting with the filter will be + listed. Default value is None. + :type filter: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. + :type expand: str + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.FileShareItems] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FileShareItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO[bytes], + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO[bytes] + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO[bytes]], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare or IO[bytes] + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IOBase, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FileShare", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO[bytes]], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a FileShare type or a + IO[bytes] type. Required. + :type file_share: ~azure.mgmt.storage.v2023_05_01.models.FileShare or IO[bytes] + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IOBase, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + share_name: str, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Gets properties of a specified share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: stats. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. + :type x_ms_snapshot: str + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.FileShare + :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._api_version or "2023-05-01")) + cls: ClsType[_models.FileShare] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + x_ms_snapshot=x_ms_snapshot, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes specified share under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. + :type x_ms_snapshot: str + :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default + value is snapshots. For 'snapshots', the file share is deleted including all of its file share + snapshots. If the file share contains leased-snapshots, the deletion fails. For + 'leased-snapshots', the file share is deleted included all of its file share snapshots + (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. + :type include: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: ~azure.mgmt.storage.v2023_05_01.models.DeletedShare + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO[bytes]], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a DeletedShare type or a IO[bytes] type. Required. + :type deleted_share: ~azure.mgmt.storage.v2023_05_01.models.DeletedShare or IO[bytes] + :return: None or the result of cls(response) + :rtype: 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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IOBase, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") + + _request = build_restore_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a LeaseShareRequest type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareRequest or IO[bytes] + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LeaseShareResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LeaseShareResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None + + _request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_local_users_operations.py new file mode 100644 index 000000000000..18f3dc431281 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_local_users_operations.py @@ -0,0 +1,808 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListLocalUserIncludeParam]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "int", maximum=5000, minimum=1) + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, username: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, account_name: str, username: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, username: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, account_name: str, username: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_password_request( + resource_group_name: str, account_name: str, username: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`local_users` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListLocalUserIncludeParam]] = None, + **kwargs: Any + ) -> Iterable["_models.LocalUser"]: + """List the local users associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of local users that will be included + in the list response. Default value is None. + :type maxpagesize: int + :param filter: Optional. When specified, only local user names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, when specified, will list local users enabled for the specific + protocol. Lists all users by default. "nfsv3" Default value is None. + :type include: str or ~azure.mgmt.storage.v2023_05_01.models.ListLocalUserIncludeParam + :return: An iterator like instance of either LocalUser or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUsers] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LocalUsers", 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) + + _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) + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: + """Get the local user of the storage account by username. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :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._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: _models.LocalUser, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. Properties + for NFSv3 enablement and extended groups cannot be set with other properties. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. Properties + for NFSv3 enablement and extended groups cannot be set with other properties. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO[bytes]], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. Properties + for NFSv3 enablement and extended groups cannot be set with other properties. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a LocalUser type + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.LocalUser or IO[bytes] + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUser + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LocalUser] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> None: + """Deletes the local user associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_keys( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserKeys: + """List SSH authorized keys and shared key of the local user. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: LocalUserKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUserKeys + :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._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUserKeys] = kwargs.pop("cls", None) + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def regenerate_password( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserRegeneratePasswordResult: + """Regenerate the local user SSH password. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :return: LocalUserRegeneratePasswordResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.LocalUserRegeneratePasswordResult + :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._api_version or "2023-05-01")) + cls: ClsType[_models.LocalUserRegeneratePasswordResult] = kwargs.pop("cls", None) + + _request = build_regenerate_password_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_management_policies_operations.py new file mode 100644 index 000000000000..cca94e4940b5 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_management_policies_operations.py @@ -0,0 +1,465 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`management_policies` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Gets the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a ManagementPolicy + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy or IO[bytes] + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagementPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> None: + """Deletes the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2023_05_01.models.ManagementPolicyName + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_network_security_perimeter_configurations_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_network_security_perimeter_configurations_operations.py new file mode 100644 index 000000000000..0169a10d74bd --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_network_security_perimeter_configurations_operations.py @@ -0,0 +1,463 @@ +# 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, Iterable, Optional, Type, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/networkSecurityPerimeterConfigurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/networkSecurityPerimeterConfigurations/{networkSecurityPerimeterConfigurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "networkSecurityPerimeterConfigurationName": _SERIALIZER.url( + "network_security_perimeter_configuration_name", + network_security_perimeter_configuration_name, + "str", + pattern=r"^.*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reconcile_request( + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/networkSecurityPerimeterConfigurations/{networkSecurityPerimeterConfigurationName}/reconcile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "networkSecurityPerimeterConfigurationName": _SERIALIZER.url( + "network_security_perimeter_configuration_name", + network_security_perimeter_configuration_name, + "str", + pattern=r"^.*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class NetworkSecurityPerimeterConfigurationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`network_security_perimeter_configurations` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets list of effective NetworkSecurityPerimeterConfiguration for storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfigurationList", 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) + + _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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets effective NetworkSecurityPerimeterConfiguration for association. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.NetworkSecurityPerimeterConfiguration + :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._api_version or "2023-05-01")) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _reconcile_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_reconcile_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_reconcile( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refreshes any information about the association. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._reconcile_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_object_replication_policies_operations.py new file mode 100644 index 000000000000..31b830139956 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_object_replication_policies_operations.py @@ -0,0 +1,593 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, object_replication_policy_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, account_name: str, object_replication_policy_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, object_replication_policy_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`object_replication_policies` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: + """List the object replication policies associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either ObjectReplicationPolicy or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ObjectReplicationPolicies] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ObjectReplicationPolicies", 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) + + _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) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Get the object replication policy of the storage account by policy ID. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO[bytes]], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a ObjectReplicationPolicy type or a IO[bytes] type. + Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy or IO[bytes] + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ObjectReplicationPolicy + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ObjectReplicationPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> None: + """Deletes the object replication policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_operations.py new file mode 100644 index 000000000000..4a22fa107df6 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_operations.py @@ -0,0 +1,156 @@ +# 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, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_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", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") + + # 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 Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`operations` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available Storage Rest API operations. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.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", self._api_version or "2023-05-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..208024e89447 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,591 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request( + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List all the private endpoint connections associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :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._api_version or "2023-05-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection or IO[bytes] + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateEndpointConnection + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") + + _request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + """Deletes the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..97fbf7cfb78f --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_private_link_resources_operations.py @@ -0,0 +1,155 @@ +# 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.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_by_storage_account_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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 PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`private_link_resources` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_storage_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.PrivateLinkResourceListResult + :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._api_version or "2023-05-01")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_list_by_storage_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_queue_operations.py new file mode 100644 index 000000000000..0f1af08d4e05 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_queue_operations.py @@ -0,0 +1,824 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_create_request( + resource_group_name: str, account_name: str, queue_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, queue_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, queue_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, queue_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`queue` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: 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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO[bytes]], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue or IO[bytes] + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IOBase, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: 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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO[bytes]], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a StorageQueue type + or a IO[bytes] type. Required. + :type queue: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue or IO[bytes] + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IOBase, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: + """Gets the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageQueue + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageQueue] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any + ) -> None: + """Deletes the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ListQueue"]: + """Gets a list of all the queues under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, a maximum number of queues that should be included in a list + queue response. Default value is None. + :type maxpagesize: str + :param filter: Optional, When specified, only the queues with a name starting with the given + filter will be listed. Default value is None. + :type filter: str + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListQueueResource] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListQueueResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_queue_services_operations.py new file mode 100644 index 000000000000..5000085e380e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_queue_services_operations.py @@ -0,0 +1,437 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_set_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") + 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.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`queue_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: + """List all queue services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: ListQueueServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListQueueServices + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ListQueueServices] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListQueueServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + QueueServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties or IO[bytes] + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :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 = 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._api_version or "2023-05-01")) + queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.QueueServiceProperties: + """Gets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.QueueServiceProperties + :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._api_version or "2023-05-01")) + queue_service_name: Literal["default"] = kwargs.pop("queue_service_name", "default") + cls: ClsType[_models.QueueServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_skus_operations.py new file mode 100644 index 000000000000..bb41df7d34a8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_skus_operations.py @@ -0,0 +1,162 @@ +# 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, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`skus` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: + """Lists the available SKUs supported by Microsoft.Storage for given subscription. + + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageSkuListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageSkuListResult", 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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..2574c28e8b16 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_accounts_operations.py @@ -0,0 +1,2796 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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}/providers/Microsoft.Storage/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_create_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_get_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + expand: Literal["kerb"] = "kerb", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_key_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_list_account_sas_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_list_service_sas_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_failover_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + failover_type: Literal["Planned"] = "Planned", + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if failover_type is not None: + _params["failoverType"] = _SERIALIZER.query("failover_type", failover_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_hierarchical_namespace_migration_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["requestType"] = _SERIALIZER.query("request_type", request_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_abort_hierarchical_namespace_migration_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_customer_initiated_migration_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/startAccountMigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_get_customer_initiated_migration_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + migration_name: Union[str, _models.MigrationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/accountMigrations/{migrationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "migrationName": _SERIALIZER.url("migration_name", migration_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_blob_ranges_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_revoke_user_delegation_keys_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`storage_accounts` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + def check_name_availability( + self, + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a StorageAccountCheckNameAvailabilityParameters type or a + IO[bytes] type. Required. + :type account_name: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCheckNameAvailabilityParameters or + IO[bytes] + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.CheckNameAvailabilityResult + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IOBase, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") + + _request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :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 + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a + StorageAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountCreateParameters or + IO[bytes] + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageAccount", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.StorageAccount].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.StorageAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_properties( + self, + resource_group_name: str, + account_name: str, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, + **kwargs: Any + ) -> _models.StorageAccount: + """Returns the properties for the specified storage account including but not limited to name, SKU + name, location, and account status. The ListKeys operation should be used to retrieve storage + keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: May be used to expand the properties within account's properties. By default, + data is not included when fetching properties. Currently we only support geoReplicationStats + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. + :type expand: str or ~azure.mgmt.storage.v2023_05_01.models.StorageAccountExpand + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + _request = build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a + StorageAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountUpdateParameters or + IO[bytes] + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccount + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_keys( + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage + account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" and None. Default value is "kerb". + :type expand: str + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) + + _request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountRegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: 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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO[bytes]], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a StorageAccountRegenerateKeyParameters type or a IO[bytes] type. + Required. + :type regenerate_key: + ~azure.mgmt.storage.v2023_05_01.models.StorageAccountRegenerateKeyParameters or IO[bytes] + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountListKeysResult + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountListKeysResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IOBase, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") + + _request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.AccountSasParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a AccountSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.AccountSasParameters or IO[bytes] + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListAccountSasResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ListAccountSasResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") + + _request = build_list_account_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ServiceSasParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a + ServiceSasParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.ServiceSasParameters or IO[bytes] + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListServiceSasResponse + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ListServiceSasResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") + + _request = build_list_service_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _failover_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_failover_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + failover_type=failover_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def begin_failover( + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> LROPoller[None]: + """A failover request can be triggered for a storage account in the event a primary endpoint + becomes unavailable for any reason. The failover occurs from the storage account's primary + cluster to the secondary cluster for RA-GRS accounts. The secondary cluster will become primary + after failover and the account is converted to LRS. In the case of a Planned Failover, the + primary and secondary clusters are swapped after failover and the account remains + geo-replicated. Failover should continue to be used in the event of availability issues as + Planned failover is only available while the primary and secondary endpoints are available. The + primary use case of a Planned Failover is disaster recovery testing drills. This type of + failover is invoked by setting FailoverType parameter to 'Planned'. Learn more about the + failover options here- + https://learn.microsoft.com/en-us/azure/storage/common/storage-disaster-recovery-guidance. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover + is requested. Known values are "Planned" and None. Default value is "Planned". + :type failover_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._failover_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + failover_type=failover_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + request_type=request_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> LROPoller[None]: + """Live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param request_type: Required. Hierarchical namespace migration type can either be a + hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request + 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the + hydration request will migrate the account. Required. + :type request_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + request_type=request_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_abort_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def begin_abort_hierarchical_namespace_migration( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Abort live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + 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._abort_hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _customer_initiated_migration_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountMigration, IO[bytes]], + **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountMigration") + + _request = build_customer_initiated_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + def begin_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountMigration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Account Migration request can be triggered for a storage account to change its redundancy + level. The migration updates the non-zonal redundant storage account to a zonal redundant + account or vice-versa in order to have better reliability and availability. Zone-redundant + storage (ZRS) replicates your storage account synchronously across three Azure availability + zones in the primary region. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The request parameters required to perform storage account migration. + Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMigration + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Account Migration request can be triggered for a storage account to change its redundancy + level. The migration updates the non-zonal redundant storage account to a zonal redundant + account or vice-versa in order to have better reliability and availability. Zone-redundant + storage (ZRS) replicates your storage account synchronously across three Azure availability + zones in the primary region. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The request parameters required to perform storage account migration. + Required. + :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 + :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: + """ + + @distributed_trace + def begin_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountMigration, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Account Migration request can be triggered for a storage account to change its redundancy + level. The migration updates the non-zonal redundant storage account to a zonal redundant + account or vice-versa in order to have better reliability and availability. Zone-redundant + storage (ZRS) replicates your storage account synchronously across three Azure availability + zones in the primary region. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The request parameters required to perform storage account migration. Is + either a StorageAccountMigration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMigration or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._customer_initiated_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_customer_initiated_migration( + self, + resource_group_name: str, + account_name: str, + migration_name: Union[str, _models.MigrationName], + **kwargs: Any + ) -> _models.StorageAccountMigration: + """Gets the status of the ongoing migration for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param migration_name: The name of the Storage Account Migration. It should always be + 'default'. "default" Required. + :type migration_name: str or ~azure.mgmt.storage.v2023_05_01.models.MigrationName + :return: StorageAccountMigration or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageAccountMigration + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageAccountMigration] = kwargs.pop("cls", None) + + _request = build_get_customer_initiated_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + migration_name=migration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountMigration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _restore_blob_ranges_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], + **kwargs: Any + ) -> _models.BlobRestoreStatus: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobRestoreStatus] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") + + _request = build_restore_blob_ranges_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :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 + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a + BlobRestoreParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.BlobRestoreParameters or IO[bytes] + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.BlobRestoreStatus] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BlobRestoreStatus] = 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_blob_ranges_initial( + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BlobRestoreStatus].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BlobRestoreStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Revoke user delegation keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_revoke_user_delegation_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignment_instances_report_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignment_instances_report_operations.py new file mode 100644 index 000000000000..da207b08d865 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignment_instances_report_operations.py @@ -0,0 +1,227 @@ +# 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, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request( + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}/reports", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "storageTaskAssignmentName": _SERIALIZER.url( + "storage_task_assignment_name", + storage_task_assignment_name, + "str", + max_length=24, + min_length=3, + pattern=r"^[a-z0-9]{3,24}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _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 StorageTaskAssignmentInstancesReportOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`storage_task_assignment_instances_report` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.StorageTaskReportInstance"]: + """Fetch the report summary of a single storage task assignment's instances. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param maxpagesize: Optional, specifies the maximum number of storage task assignment instances + to be included in the list response. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, it can be used to query using reporting properties. + See `Constructing Filter Strings + `_ + for details. Default value is None. + :type filter: str + :return: An iterator like instance of either StorageTaskReportInstance or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskReportSummary] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageTaskReportSummary", 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignments_instances_report_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignments_instances_report_operations.py new file mode 100644 index 000000000000..17a3ba370455 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignments_instances_report_operations.py @@ -0,0 +1,212 @@ +# 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, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/reports", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _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 StorageTaskAssignmentsInstancesReportOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`storage_task_assignments_instances_report` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.StorageTaskReportInstance"]: + """Fetch the report summary of all the storage task assignments and instances in an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of storage task assignment instances + to be included in the list response. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, it can be used to query using reporting properties. + See `Constructing Filter Strings + `_ + for details. Default value is None. + :type filter: str + :return: An iterator like instance of either StorageTaskReportInstance or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageTaskReportInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskReportSummary] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageTaskReportSummary", 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignments_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignments_operations.py new file mode 100644 index 000000000000..6228de367133 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_storage_task_assignments_operations.py @@ -0,0 +1,1018 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_create_request( + resource_group_name: str, account_name: str, storage_task_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "storageTaskAssignmentName": _SERIALIZER.url( + "storage_task_assignment_name", + storage_task_assignment_name, + "str", + max_length=24, + min_length=3, + pattern=r"^[a-z0-9]{3,24}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, storage_task_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "storageTaskAssignmentName": _SERIALIZER.url( + "storage_task_assignment_name", + storage_task_assignment_name, + "str", + max_length=24, + min_length=3, + pattern=r"^[a-z0-9]{3,24}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, storage_task_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "storageTaskAssignmentName": _SERIALIZER.url( + "storage_task_assignment_name", + storage_task_assignment_name, + "str", + max_length=24, + min_length=3, + pattern=r"^[a-z0-9]{3,24}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, storage_task_assignment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/storageTaskAssignments/{storageTaskAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "storageTaskAssignmentName": _SERIALIZER.url( + "storage_task_assignment_name", + storage_task_assignment_name, + "str", + max_length=24, + min_length=3, + pattern=r"^[a-z0-9]{3,24}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/storageTaskAssignments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + _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 StorageTaskAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`storage_task_assignments` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignment, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.StorageTaskAssignment]: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageTaskAssignment]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageTaskAssignment") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("StorageTaskAssignment", 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) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: _models.StorageTaskAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageTaskAssignment]: + """Asynchronously creates a new storage task assignment sub-resource with the specified + parameters. If a storage task assignment is already created and a subsequent create request is + issued with different properties, the storage task assignment properties will be updated. If a + storage task assignment is already created and a subsequent create or update request is issued + with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to create a Storage Task Assignment. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment + :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 StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageTaskAssignment]: + """Asynchronously creates a new storage task assignment sub-resource with the specified + parameters. If a storage task assignment is already created and a subsequent create request is + issued with different properties, the storage task assignment properties will be updated. If a + storage task assignment is already created and a subsequent create or update request is issued + with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to create a Storage Task Assignment. Required. + :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 + :return: An instance of LROPoller that returns either StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignment, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.StorageTaskAssignment]: + """Asynchronously creates a new storage task assignment sub-resource with the specified + parameters. If a storage task assignment is already created and a subsequent create request is + issued with different properties, the storage task assignment properties will be updated. If a + storage task assignment is already created and a subsequent create or update request is issued + with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to create a Storage Task Assignment. Is either a + StorageTaskAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment or IO[bytes] + :return: An instance of LROPoller that returns either StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageTaskAssignment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.StorageTaskAssignment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.StorageTaskAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignmentUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.StorageTaskAssignment]: + 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageTaskAssignment]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageTaskAssignmentUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("StorageTaskAssignment", 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) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: _models.StorageTaskAssignmentUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageTaskAssignment]: + """Update storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to update a Storage Task Assignment. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateParameters + :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 StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageTaskAssignment]: + """Update storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to update a Storage Task Assignment. Required. + :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 + :return: An instance of LROPoller that returns either StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + storage_task_assignment_name: str, + parameters: Union[_models.StorageTaskAssignmentUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.StorageTaskAssignment]: + """Update storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :param parameters: The parameters to update a Storage Task Assignment. Is either a + StorageTaskAssignmentUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignmentUpdateParameters + or IO[bytes] + :return: An instance of LROPoller that returns either StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageTaskAssignment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.StorageTaskAssignment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.StorageTaskAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, storage_task_assignment_name: str, **kwargs: Any + ) -> _models.StorageTaskAssignment: + """Get the storage task assignment properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :return: StorageTaskAssignment or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment + :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._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageTaskAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, storage_task_assignment_name: str, **kwargs: Any + ) -> None: + 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, 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")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, storage_task_assignment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete the storage task assignment sub-resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param storage_task_assignment_name: The name of the storage task assignment within the + specified resource group. Storage task assignment names must be between 3 and 24 characters in + length and use numbers and lower-case letters only. Required. + :type storage_task_assignment_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + storage_task_assignment_name=storage_task_assignment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, maxpagesize: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.StorageTaskAssignment"]: + """List all the storage task assignments in an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of storage task assignment Ids to be + included in the list response. Default value is None. + :type maxpagesize: str + :return: An iterator like instance of either StorageTaskAssignment or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.StorageTaskAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.StorageTaskAssignmentsList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageTaskAssignmentsList", 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.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_table_operations.py new file mode 100644 index 000000000000..0950d5cfb466 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_table_operations.py @@ -0,0 +1,775 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_create_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + 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.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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 TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`table` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table or IO[bytes] + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Table] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a Table type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.Table or IO[bytes] + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :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 = 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._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Table] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: + """Gets the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.Table + :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._api_version or "2023-05-01")) + cls: ClsType[_models.Table] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> None: + """Deletes the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :return: None or the result of cls(response) + :rtype: 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._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: + """Gets a list of all the tables under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ListTableResource] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListTableResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_table_services_operations.py new file mode 100644 index 000000000000..509118c8dea7 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_table_services_operations.py @@ -0,0 +1,437 @@ +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_set_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") + 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.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-z0-9]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`table_services` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: + """List all table services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: ListTableServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.ListTableServices + :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._api_version or "2023-05-01")) + cls: ClsType[_models.ListTableServices] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListTableServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO[bytes]], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + TableServiceProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties or IO[bytes] + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :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 = 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._api_version or "2023-05-01")) + table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") + + _request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + content_type=content_type, + json=_json, + content=_content, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.TableServiceProperties: + """Gets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2023_05_01.models.TableServiceProperties + :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._api_version or "2023-05-01")) + table_service_name: Literal["default"] = kwargs.pop("table_service_name", "default") + cls: ClsType[_models.TableServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_usages_operations.py new file mode 100644 index 000000000000..a14425f4335a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/operations/_usages_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, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +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_list_by_location_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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 UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2023_05_01.StorageManagementClient`'s + :attr:`usages` 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") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: + """Gets the current usage count and the limit for the resources of the location under the + subscription. + + :param location: The location of the Azure Storage resource. Required. + :type location: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2023_05_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UsageListResult", 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) + + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/py.typed b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2023_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_clear_legal_hold.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_clear_legal_hold.py index 26cfa0c826a1..0546c07a8fd4 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_clear_legal_hold.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_clear_legal_hold.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersClearLegalHold.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersClearLegalHold.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete.py index e49677724b3b..0647bea170e6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete_immutability_policy.py index 2ff23068ac3a..10afc162b462 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_delete_immutability_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersDeleteImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersDeleteImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_extend_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_extend_immutability_policy.py index 957cd8ce2446..9125b544d398 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_extend_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_extend_immutability_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersExtendImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersExtendImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get.py index c533a4760b4a..81f028c9b85d 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_immutability_policy.py index 9bed80c8b199..7a22c6bed5e2 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_immutability_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersGetImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_with_allow_protected_append_writes_all.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_with_allow_protected_append_writes_all.py index 35ffb17f841f..48ffa555e419 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_with_allow_protected_append_writes_all.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_get_with_allow_protected_append_writes_all.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_acquire.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_acquire.py index a906c68ebf48..968c5d1f6c09 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_acquire.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_acquire.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersLease_Acquire.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersLease_Acquire.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_break.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_break.py index e825b62e3762..3db1886c8fd6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_break.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lease_break.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersLease_Break.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersLease_Break.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_list.py index cffc69a3030c..0bff302e7c41 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lock_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lock_immutability_policy.py index ce0e9c6a0410..c3ce51f495fe 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lock_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_lock_immutability_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersLockImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersLockImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_patch.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_patch.py index 5b9bb91c551b..c047abeebb38 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_patch.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_patch.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersPatch.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPatch.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_default_encryption_scope.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_default_encryption_scope.py index 1b0e4511f9e7..f9b77e9611f6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_default_encryption_scope.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_default_encryption_scope.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersPutDefaultEncryptionScope.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutDefaultEncryptionScope.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy.py index 7b1ad45d9339..1ba027c17945 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersPutImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy_allow_protected_append_writes_all.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy_allow_protected_append_writes_all.py index 5bb5b7cb2db9..ff5e031fefd2 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy_allow_protected_append_writes_all.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_immutability_policy_allow_protected_append_writes_all.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersPutImmutabilityPolicyAllowProtectedAppendWritesAll.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutImmutabilityPolicyAllowProtectedAppendWritesAll.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_object_level_worm.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_object_level_worm.py index ff3bf21a7f98..14030b7fd92c 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_object_level_worm.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_put_object_level_worm.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersPutObjectLevelWorm.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutObjectLevelWorm.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold.py index 1b2726d028ba..8aba138a7a16 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersSetLegalHold.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersSetLegalHold.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold_allow_protected_append_writes_all.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold_allow_protected_append_writes_all.py index 4cd8f40c1fb8..ed3afe33b3dc 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold_allow_protected_append_writes_all.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_containers_set_legal_hold_allow_protected_append_writes_all.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobContainersSetLegalHoldAllowProtectedAppendWritesAll.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersSetLegalHoldAllowProtectedAppendWritesAll.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_ranges_restore.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_ranges_restore.py index 0072654ea2a8..87345687a7c0 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_ranges_restore.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_ranges_restore.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -43,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobRangesRestore.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobRangesRestore.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_get.py index 78124bcdc4ed..a4cf68c61cf9 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobServicesGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_list.py index 32484affc599..966b2eff5d5f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobServicesList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put.py index 5857f6835261..8d7333f0e759 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -69,6 +72,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobServicesPut.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesPut.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_allow_permanent_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_allow_permanent_delete.py index 947439f00771..02431ce8c2c8 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_allow_permanent_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_allow_permanent_delete.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobServicesPutAllowPermanentDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesPutAllowPermanentDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_last_access_time_based_tracking.py b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_last_access_time_based_tracking.py index 58a4a32a2de0..ca7a52356b80 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_last_access_time_based_tracking.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/blob_services_put_last_access_time_based_tracking.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/BlobServicesPutLastAccessTimeBasedTracking.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesPutLastAccessTimeBasedTracking.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_get.py index 07a08566e4fa..ba8d33411c5c 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/DeletedAccountGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedAccountGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_list.py index acfaaac2b669..e3ebe4a1035f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_account_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/DeletedAccountList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedAccountList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_blob_containers_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_blob_containers_list.py index da4038258219..2fd7a6e1368e 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_blob_containers_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_blob_containers_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/DeletedBlobContainersList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedBlobContainersList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_file_shares_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_file_shares_list.py index ebfaebe3ae90..e36f575e7f0c 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/deleted_file_shares_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/deleted_file_shares_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/DeletedFileSharesList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedFileSharesList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_get.py index 1f748815163e..1c2bf1e2edcd 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileServicesGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_list.py index c5ff2c0a8b80..cbd54d1e6a8d 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileServicesList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put.py index 764fd013233a..3c8a31f1da50 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileServicesPut.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_secure_smb_features.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_secure_smb_features.py index 5574d1fee1cb..5317baba8232 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_secure_smb_features.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_secure_smb_features.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -48,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileServicesPut_EnableSecureSmbFeatures.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut_EnableSecureSmbFeatures.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_smb_multichannel.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_smb_multichannel.py index 619bb5bc9864..384d000492b4 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_smb_multichannel.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_services_put_enable_smb_multichannel.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileServicesPut_EnableSMBMultichannel.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut_EnableSMBMultichannel.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_share_acls_patch.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_share_acls_patch.py index b1a7c3458449..287ea96f5ee6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_share_acls_patch.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_share_acls_patch.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -51,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileShareAclsPatch.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileShareAclsPatch.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_share_snapshots_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_share_snapshots_list.py index dd3d75ee3656..192b576cca84 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_share_snapshots_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_share_snapshots_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileShareSnapshotsList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileShareSnapshotsList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_delete.py index 6d4dcaabc1af..67d728b6833e 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get.py index 5e9b6546e14b..d32599aa7432 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get_stats.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get_stats.py index e63fbeeea805..fc620ded54b5 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get_stats.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_get_stats.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesGet_Stats.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_acquire.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_acquire.py index 92a99a9fd810..1a617340938f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_acquire.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_acquire.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Acquire.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesLease_Acquire.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_break.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_break.py index b22dd64d0def..1265433c6195 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_break.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_lease_break.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Break.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesLease_Break.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_list.py index 9397075f3557..d993e582b6cc 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_patch.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_patch.py index bcaba64003da..12117c36f6ea 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_patch.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_patch.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesPatch.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPatch.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_access_tier.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_access_tier.py index 43d833ebc633..1e569c217ff6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_access_tier.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_access_tier.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesPut_AccessTier.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut_AccessTier.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_nfs.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_nfs.py index 3c36e3640c16..aeb4757e623d 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_nfs.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_put_nfs.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesPut_NFS.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut_NFS.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_restore.py b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_restore.py index 7f474f37f53c..a48b7319547a 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_restore.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/file_shares_restore.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesRestore.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesRestore.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create.py index 0701764c3c71..86a58f18e116 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +38,8 @@ def main(): username="user1", properties={ "properties": { + "allowAclAuthorization": True, + "groupId": 2000, "hasSshPassword": True, "homeDirectory": "homedirectory", "permissionScopes": [ @@ -48,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUserCreate.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserCreate.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create_nf_sv3_enabled.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create_nf_sv3_enabled.py new file mode 100644 index 000000000000..345bba3efcc9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_create_nf_sv3_enabled.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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python local_user_create_nf_sv3_enabled.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.local_users.create_or_update( + resource_group_name="res6977", + account_name="sto2527", + username="user1", + properties={"properties": {"extendedGroups": [1001, 1005, 2005], "isNFSv3Enabled": True}}, + ) + print(response) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserCreateNFSv3Enabled.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_delete.py index e817b58d3f34..83e8b8f8fa5b 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUserDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_get.py index 46abb06eaf0b..c05559860406 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUserGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_list_keys.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_list_keys.py index 7cd3ca4d0349..2600b58407e7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_list_keys.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_list_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUserListKeys.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserListKeys.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_regenerate_password.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_regenerate_password.py index 4f0a86f9a752..f28f54ceb654 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_regenerate_password.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_regenerate_password.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUserRegeneratePassword.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserRegeneratePassword.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_update.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_update.py index 07fd1dfec616..0dae42be8134 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_user_update.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_user_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,16 +38,20 @@ def main(): username="user1", properties={ "properties": { + "allowAclAuthorization": False, + "extendedGroups": [1001, 1005, 2005], + "groupId": 3000, "hasSharedKey": False, "hasSshKey": False, "hasSshPassword": False, "homeDirectory": "homedirectory2", + "isNFSv3Enabled": True, } }, ) print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUserUpdate.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserUpdate.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list.py index 3867b540a561..1b5668769d98 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/LocalUsersList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUsersList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list_nf_sv3_enabled.py b/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list_nf_sv3_enabled.py new file mode 100644 index 000000000000..432234d5f5e8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/local_users_list_nf_sv3_enabled.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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python local_users_list_nf_sv3_enabled.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.local_users.list( + resource_group_name="res6977", + account_name="sto2527", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUsersListNFSv3Enabled.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_get.py new file mode 100644 index 000000000000..79c700d56bf9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_get.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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python network_security_perimeter_configuration_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.network_security_perimeter_configurations.get( + resource_group_name="res4410", + account_name="sto8607", + network_security_perimeter_configuration_name="dbedb4e0-40e6-4145-81f3-f1314c150774.resourceAssociation1", + ) + print(response) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationGet.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_list.py new file mode 100644 index 000000000000..6ac0f53f55b7 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_list.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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python network_security_perimeter_configuration_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, + 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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.network_security_perimeter_configurations.list( + resource_group_name="res4410", + account_name="sto8607", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationList.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_reconcile.py b/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_reconcile.py new file mode 100644 index 000000000000..dd3d8ef7ee24 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/network_security_perimeter_configuration_reconcile.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python network_security_perimeter_configuration_reconcile.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + client.network_security_perimeter_configurations.begin_reconcile( + resource_group_name="res4410", + account_name="sto8607", + network_security_perimeter_configuration_name="dbedb4e0-40e6-4145-81f3-f1314c150774.resourceAssociation1", + ).result() + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationReconcile.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/nfs_v3_account_create.py b/sdk/storage/azure-mgmt-storage/generated_samples/nfs_v3_account_create.py index 887c98c444c6..5f8d6c779983 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/nfs_v3_account_create.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/nfs_v3_account_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +39,7 @@ def main(): "kind": "BlockBlobStorage", "location": "eastus", "properties": { + "enableExtendedGroups": True, "isHnsEnabled": True, "isNfsV3Enabled": True, "networkAcls": { @@ -56,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/NfsV3AccountCreate.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NfsV3AccountCreate.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/object_level_worm_container_migration.py b/sdk/storage/azure-mgmt-storage/generated_samples/object_level_worm_container_migration.py index c1064b50a351..26d30a90e301 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/object_level_worm_container_migration.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/object_level_worm_container_migration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/ObjectLevelWormContainerMigration.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/ObjectLevelWormContainerMigration.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/operations_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/operations_list.py index 13a8b43c5d23..84a6d96cb7ad 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/operations_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/OperationsList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_delete.py index d52d61ae6e7a..eba135f88343 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueOperationDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_get.py index 2fe4ed0f3301..153545cb62af 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueOperationGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_list.py index fd6df697ddef..215a93cc2d12 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueOperationList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_put_with_metadata.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_put_with_metadata.py index 9a605261104d..69e9ab2d0f9f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_put_with_metadata.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_operation_put_with_metadata.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueOperationPutWithMetadata.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationPutWithMetadata.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_get.py index 792f37e2edbd..c2896553fd57 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueServicesGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_list.py index 05c2eb25cb09..f5e00b2d8e63 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueServicesList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_put.py b/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_put.py index c8761c019382..57522ee7e201 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_put.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/queue_services_put.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/QueueServicesPut.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesPut.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/sku_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/sku_list.py index 1b4b5fa1c5e3..d1eb3e5734ca 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/sku_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/sku_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/SKUList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/SKUList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_abort_hierarchical_namespace_migration.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_abort_hierarchical_namespace_migration.py index 812107c9231a..98bac60a5ece 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_abort_hierarchical_namespace_migration.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_abort_hierarchical_namespace_migration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountAbortHierarchicalNamespaceMigration.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountAbortHierarchicalNamespaceMigration.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_check_name_availability.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_check_name_availability.py index a783f570377d..eedccac9cefd 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_check_name_availability.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_check_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCheckNameAvailability.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create.py index 217009ccc11b..d28e4807c29f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -66,6 +69,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreate.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreate.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_aad.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_aad.py index 620bfb046dac..8ef790ad73ad 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_aad.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_aad.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -64,6 +67,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateAllowedCopyScopeToAAD.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateAllowedCopyScopeToAAD.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_private_link.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_private_link.py index 95d75335a8e7..9513936e0903 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_private_link.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_allowed_copy_scope_to_private_link.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -64,6 +67,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateAllowedCopyScopeToPrivateLink.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateAllowedCopyScopeToPrivateLink.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_disallow_public_network_access.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_disallow_public_network_access.py index e1949d6cbc50..30da22af8cc7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_disallow_public_network_access.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_disallow_public_network_access.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateDisallowPublicNetworkAccess.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateDisallowPublicNetworkAccess.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_azure_dns_zone.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_azure_dns_zone.py index e748ce5d1f39..f6bd2c07ad4d 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_azure_dns_zone.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_azure_dns_zone.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -67,6 +70,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateDnsEndpointTypeToAzureDnsZone.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateDnsEndpointTypeToAzureDnsZone.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_standard.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_standard.py index 12ddf2bdf75d..58751957d828 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_standard.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_dns_endpoint_type_to_standard.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -67,6 +70,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateDnsEndpointTypeToStandard.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateDnsEndpointTypeToStandard.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_enable_public_network_access.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_enable_public_network_access.py index 22eb620ae10a..70b64f3ea3bd 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_enable_public_network_access.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_enable_public_network_access.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateEnablePublicNetworkAccess.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateEnablePublicNetworkAccess.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_destination.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_destination.py index 7791d30d9659..51d5767bd151 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_destination.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_destination.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -50,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_source.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_source.py index 07ccf616c73a..2eb549054fde 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_source.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_object_replication_policy_on_source.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -51,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_premium_block_blob_storage.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_premium_block_blob_storage.py index 5921d3d80b9c..0c680d6c770b 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_premium_block_blob_storage.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_premium_block_blob_storage.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -54,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreatePremiumBlockBlobStorage.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreatePremiumBlockBlobStorage.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_encryption_identity_with_cmk.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_encryption_identity_with_cmk.py index 7fadeeb17275..c453021b7c99 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_encryption_identity_with_cmk.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_encryption_identity_with_cmk.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -64,6 +67,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateUserAssignedEncryptionIdentityWithCMK.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateUserAssignedEncryptionIdentityWithCMK.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_identity_with_federated_identity_client_id.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_identity_with_federated_identity_client_id.py index 8f89fdaccdff..4876aa1aeab9 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_identity_with_federated_identity_client_id.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_user_assigned_identity_with_federated_identity_client_id.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateUserAssignedIdentityWithFederatedIdentityClientId.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateUserAssignedIdentityWithFederatedIdentityClientId.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_with_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_with_immutability_policy.py index 15f9f37b3264..130ed2a64ea2 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_with_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_create_with_immutability_policy.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -52,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountCreateWithImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateWithImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete.py index e2145c3c827d..4bf60089ef86 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_blob_inventory_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_blob_inventory_policy.py index 98fa75bbddad..2b077e9e86e0 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_blob_inventory_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_blob_inventory_policy.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -36,6 +42,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountDeleteBlobInventoryPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteBlobInventoryPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_management_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_management_policy.py index ae8309a8aef9..e306f1d46c44 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_management_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_management_policy.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -36,6 +42,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountDeleteManagementPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteManagementPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_object_replication_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_object_replication_policy.py index c2de163e2772..6c97fb695bb7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_object_replication_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_object_replication_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountDeleteObjectReplicationPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteObjectReplicationPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_private_endpoint_connection.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_private_endpoint_connection.py index 983d21cc96b3..a69178caf0a4 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_private_endpoint_connection.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_delete_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountDeletePrivateEndpointConnection.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_ad.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_ad.py index fe868ef40e09..4bef5a6a1b5d 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_ad.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_ad.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountEnableAD.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountEnableAD.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_cmk.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_cmk.py index b4b8b35b2407..514e37910926 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_cmk.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_enable_cmk.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -52,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountEnableCMK.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountEnableCMK.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_encryption_scope_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_encryption_scope_list.py index 63b0ac34b563..79d9cf443805 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_encryption_scope_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_encryption_scope_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountEncryptionScopeList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountEncryptionScopeList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover.py index b158e54ad22d..bcc0d5733f24 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountFailover.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountFailover.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover_planned.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover_planned.py index bf1316bd60ef..b2a4313ed476 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover_planned.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_failover_planned.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountFailoverPlanned.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountFailoverPlanned.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_async_sku_conversion_status.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_async_sku_conversion_status.py index 5a04cb631306..1775bbfa7e09 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_async_sku_conversion_status.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_async_sku_conversion_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetAsyncSkuConversionStatus.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetAsyncSkuConversionStatus.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_blob_inventory_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_blob_inventory_policy.py index 213792e60fd7..befb7d8d224a 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_blob_inventory_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_blob_inventory_policy.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -37,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetBlobInventoryPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetBlobInventoryPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_encryption_scope.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_encryption_scope.py index bd0f657f1677..83cc5b2d8c54 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_encryption_scope.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_encryption_scope.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetEncryptionScope.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetEncryptionScope.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_management_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_management_policy.py index 8dd31ad4886b..ff04afa97bb8 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_management_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_management_policy.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -37,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetManagementPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetManagementPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_failed.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_failed.py index 7f3e8bcd5ef7..0d6c4b3c13ac 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_failed.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_failed.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -37,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetMigrationFailed.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationFailed.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_in_progress.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_in_progress.py index 051e198bba97..8ad6d7c2258e 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_in_progress.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_migration_in_progress.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -37,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetMigrationInProgress.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationInProgress.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_object_replication_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_object_replication_policy.py index 8ab1dae0b46e..524c7d62ce11 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_object_replication_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_object_replication_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetObjectReplicationPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_private_endpoint_connection.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_private_endpoint_connection.py index ed44348f2ea5..9567ba8cff60 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_private_endpoint_connection.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetPrivateEndpointConnection.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties.py index 2b494bb09e3f..2a138b095f71 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetProperties.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_enabled.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_enabled.py index 09aa5b02027f..df8e059c73d0 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_enabled.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_enabled.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetPropertiesCMKEnabled.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_version_expiration_time.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_version_expiration_time.py index 74b4d7517d9b..502c8f725b1b 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_version_expiration_time.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_cmk_version_expiration_time.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetPropertiesCMKVersionExpirationTime.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKVersionExpirationTime.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_false.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_false.py index 52708b1de540..eaafafca11e7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_false.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_false.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_true.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_true.py index 6779a0195b49..45f63690a8cd 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_true.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_get_properties_geo_replication_statscan_failover_true.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_hierarchical_namespace_migration.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_hierarchical_namespace_migration.py index 86f334f1e1e5..f34d5c6ed359 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_hierarchical_namespace_migration.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_hierarchical_namespace_migration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountHierarchicalNamespaceMigration.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountHierarchicalNamespaceMigration.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list.py index ef9ed72ef123..1b41c7b2d35e 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_account_sas.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_account_sas.py index 5514eb55c275..5a27f8a1101f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_account_sas.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_account_sas.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListAccountSAS.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListAccountSAS.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_blob_inventory_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_blob_inventory_policy.py index f3a5a6dd2475..ee849ce0f080 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_blob_inventory_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_blob_inventory_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListBlobInventoryPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListBlobInventoryPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_by_resource_group.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_by_resource_group.py index 7a4cf39544ce..270e9314b75d 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_by_resource_group.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListByResourceGroup.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_keys.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_keys.py index 7638e28dac73..b8a0a2130ab7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_keys.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListKeys.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListKeys.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_location_usage.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_location_usage.py index 11a7198ee33a..92db211ea846 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_location_usage.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_location_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListLocationUsage.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListLocationUsage.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_object_replication_policies.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_object_replication_policies.py index 0c71bf808bfd..3046ffcc93ec 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_object_replication_policies.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_object_replication_policies.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListObjectReplicationPolicies.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListObjectReplicationPolicies.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_endpoint_connections.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_endpoint_connections.py index 845a25e62248..36aac94511c3 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_endpoint_connections.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_endpoint_connections.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListPrivateEndpointConnections.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListPrivateEndpointConnections.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_link_resources.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_link_resources.py index 29995fdd48bb..599c76d24135 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_link_resources.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_private_link_resources.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListPrivateLinkResources.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_service_sas.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_service_sas.py index ef14f84ae4db..34485cb1f9d6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_service_sas.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_list_service_sas.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountListServiceSAS.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListServiceSAS.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_patch_encryption_scope.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_patch_encryption_scope.py index 9254ed49047f..ede89f35a777 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_patch_encryption_scope.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_patch_encryption_scope.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -43,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountPatchEncryptionScope.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPatchEncryptionScope.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_post_migration.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_post_migration.py index 7386230b2388..b820eb5c2d49 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_post_migration.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_post_migration.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountPostMigration.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPostMigration.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_encryption_scope_with_infrastructure_encryption.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_encryption_scope_with_infrastructure_encryption.py index 5a44c1c41e31..ef5a5a35c5ba 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_encryption_scope_with_infrastructure_encryption.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_encryption_scope_with_infrastructure_encryption.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountPutEncryptionScopeWithInfrastructureEncryption.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPutEncryptionScopeWithInfrastructureEncryption.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_private_endpoint_connection.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_private_endpoint_connection.py index 3a17f15350f3..df5057db6530 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_private_endpoint_connection.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_put_private_endpoint_connection.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountPutPrivateEndpointConnection.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPutPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_kerb_key.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_kerb_key.py index f4725d703000..b1816bc28c5e 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_kerb_key.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_kerb_key.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountRegenerateKerbKey.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountRegenerateKerbKey.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_key.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_key.py index 4acf1b7e943f..0f374fcc8f70 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_key.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_regenerate_key.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountRegenerateKey.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_revoke_user_delegation_keys.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_revoke_user_delegation_keys.py index d0749c69a39d..b2294cdf435e 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_revoke_user_delegation_keys.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_revoke_user_delegation_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountRevokeUserDelegationKeys.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountRevokeUserDelegationKeys.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy.py index 7b44ada5cc10..dd010a1365f5 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -99,6 +105,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetBlobInventoryPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetBlobInventoryPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_hns_account.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_hns_account.py index 3c076fbc0be0..d0fcfb0dc606 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_hns_account.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_hns_account.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -117,6 +123,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForHnsAccount.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForHnsAccount.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_non_hns_account.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_non_hns_account.py index ac97fe17e77d..02ea31966ee7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_non_hns_account.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_blob_inventory_policy_include_delete_and_new_schema_for_non_hns_account.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -116,6 +122,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForNonHnsAccount.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForNonHnsAccount.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy.py index bc33b215f116..02a461617cb7 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -83,6 +89,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_base_blob_days_after_creation_actions.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_base_blob_days_after_creation_actions.py index b23c3dc0251e..801436fa4c54 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_base_blob_days_after_creation_actions.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_base_blob_days_after_creation_actions.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -60,6 +66,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_cold_tier_actions.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_cold_tier_actions.py index 1dbf9a1ebb4c..deca4f8f4a14 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_cold_tier_actions.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_cold_tier_actions.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -69,6 +75,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyColdTierActions.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicyColdTierActions.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_for_block_and_append_blobs.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_for_block_and_append_blobs.py index e2b7d4fbc684..06c066ca5611 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_for_block_and_append_blobs.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_for_block_and_append_blobs.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -61,6 +67,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_hot_tier_actions.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_hot_tier_actions.py index d13f366273e5..44e6bf17bbff 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_hot_tier_actions.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_hot_tier_actions.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -58,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyHotTierActions.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicyHotTierActions.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_access_time_based_blob_actions.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_access_time_based_blob_actions.py index 27777791c42d..6b23f89588de 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_access_time_based_blob_actions.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_access_time_based_blob_actions.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -62,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_tier_change_time_actions.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_tier_change_time_actions.py index feab3f1b2b4a..d178b4fa366a 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_tier_change_time_actions.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_last_tier_change_time_actions.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -75,6 +81,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_with_snapshot_and_version.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_with_snapshot_and_version.py index e120f27a2cff..c290abc64604 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_with_snapshot_and_version.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_set_management_policy_with_snapshot_and_version.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -70,6 +76,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update.py index c50bcc60b947..4ac7e096d66f 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +40,7 @@ def main(): "allowBlobPublicAccess": False, "allowSharedKeyAccess": True, "defaultToOAuthAuthentication": False, + "enableExtendedGroups": True, "encryption": { "keySource": "Microsoft.Storage", "services": { @@ -69,6 +73,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdate.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdate.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_allowed_copy_scope_to_aad.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_allowed_copy_scope_to_aad.py index 32d9c1dee2a5..6ed234279cfb 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_allowed_copy_scope_to_aad.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_allowed_copy_scope_to_aad.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -67,6 +70,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateAllowedCopyScopeToAAD.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateAllowedCopyScopeToAAD.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_disable_public_network_access.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_disable_public_network_access.py index a28546d0e469..ba13c9837c91 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_disable_public_network_access.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_disable_public_network_access.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -67,6 +70,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateDisablePublicNetworkAccess.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateDisablePublicNetworkAccess.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_destination.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_destination.py index 077914ec1888..8e50f8cde4c6 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_destination.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_destination.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -52,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_source.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_source.py index e9337023963c..3de4bcfaabb2 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_source.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_object_replication_policy_on_source.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -56,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_encryption_identity_with_cmk.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_encryption_identity_with_cmk.py index 47ca35b36623..7843fc224281 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_encryption_identity_with_cmk.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_encryption_identity_with_cmk.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -63,6 +66,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateUserAssignedEncryptionIdentityWithCMK.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateUserAssignedEncryptionIdentityWithCMK.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_identity_with_federated_identity_client_id.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_identity_with_federated_identity_client_id.py index 087ec6c45ba5..69422b514208 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_identity_with_federated_identity_client_id.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_user_assigned_identity_with_federated_identity_client_id.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -64,6 +67,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateUserAssignedIdentityWithFederatedIdentityClientId.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateUserAssignedIdentityWithFederatedIdentityClientId.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_with_immutability_policy.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_with_immutability_policy.py index 3b253af47db6..d7a40480b31a 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_with_immutability_policy.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_account_update_with_immutability_policy.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -48,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountUpdateWithImmutabilityPolicy.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateWithImmutabilityPolicy.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/delete_storage_task_assignment.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/delete_storage_task_assignment.py new file mode 100644 index 000000000000..8582d8da9440 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/delete_storage_task_assignment.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python delete_storage_task_assignment.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + client.storage_task_assignments.begin_delete( + resource_group_name="res4228", + account_name="sto4445", + storage_task_assignment_name="myassignment1", + ).result() + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/DeleteStorageTaskAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/get_storage_task_assignment.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/get_storage_task_assignment.py new file mode 100644 index 000000000000..9ebb2e93f17a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/get_storage_task_assignment.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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python get_storage_task_assignment.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignments.get( + resource_group_name="res4228", + account_name="sto4445", + storage_task_assignment_name="myassignment1", + ) + print(response) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/GetStorageTaskAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/patch_storage_task_assignment.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/patch_storage_task_assignment.py new file mode 100644 index 000000000000..64f9965138c2 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/patch_storage_task_assignment.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python patch_storage_task_assignment.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignments.begin_update( + resource_group_name="res4228", + account_name="sto4445", + storage_task_assignment_name="myassignment1", + parameters={ + "properties": { + "description": "My Storage task assignment", + "enabled": True, + "executionContext": { + "target": {"excludePrefix": [], "prefix": ["prefix1", "prefix2"]}, + "trigger": {"parameters": {"startOn": "2022-11-15T21:52:47.8145095Z"}, "type": "RunOnce"}, + }, + "report": {"prefix": "container1"}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/PatchStorageTaskAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/put_storage_task_assignment.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/put_storage_task_assignment.py new file mode 100644 index 000000000000..44524c64b5f2 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/put_storage_task_assignment.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python put_storage_task_assignment.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignments.begin_create( + resource_group_name="res4228", + account_name="sto4445", + storage_task_assignment_name="myassignment1", + parameters={ + "properties": { + "description": "My Storage task assignment", + "enabled": True, + "executionContext": { + "target": {"excludePrefix": [], "prefix": ["prefix1", "prefix2"]}, + "trigger": {"parameters": {"startOn": "2022-11-15T21:52:47.8145095Z"}, "type": "RunOnce"}, + }, + "report": {"prefix": "container1"}, + "taskId": "/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.StorageActions/storageTasks/mytask1", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/PutStorageTaskAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/put_storage_task_assignment_required_properties.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/put_storage_task_assignment_required_properties.py new file mode 100644 index 000000000000..f687d4872a77 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_crud/put_storage_task_assignment_required_properties.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python put_storage_task_assignment_required_properties.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignments.begin_create( + resource_group_name="res4228", + account_name="sto4445", + storage_task_assignment_name="myassignment1", + parameters={ + "properties": { + "description": "My Storage task assignment", + "enabled": True, + "executionContext": { + "trigger": {"parameters": {"startOn": "2022-11-15T21:52:47.8145095Z"}, "type": "RunOnce"} + }, + "report": {"prefix": "container1"}, + "taskId": "/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.StorageActions/storageTasks/mytask1", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/PutStorageTaskAssignmentRequiredProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignment_instances_report_summary.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignment_instances_report_summary.py new file mode 100644 index 000000000000..c8aa32b58dec --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignment_instances_report_summary.py @@ -0,0 +1,44 @@ +# 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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python list_storage_task_assignment_instances_report_summary.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignment_instances_report.list( + resource_group_name="res4228", + account_name="sto4445", + storage_task_assignment_name="myassignment1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsList/ListStorageTaskAssignmentInstancesReportSummary.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignments_for_account.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignments_for_account.py new file mode 100644 index 000000000000..a51ec649b012 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignments_for_account.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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python list_storage_task_assignments_for_account.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignments.list( + resource_group_name="res4228", + account_name="sto4445", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsList/ListStorageTaskAssignmentsForAccount.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignments_instances_report_summary.py b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignments_instances_report_summary.py new file mode 100644 index 000000000000..9a7284368335 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/generated_samples/storage_task_assignments_list/list_storage_task_assignments_instances_report_summary.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.storage import StorageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-storage +# USAGE + python list_storage_task_assignments_instances_report_summary.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 = StorageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1f31ba14-ce16-4281-b9b4-3e78da6e1616", + ) + + response = client.storage_task_assignments_instances_report.list( + resource_group_name="res4228", + account_name="sto4445", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsList/ListStorageTaskAssignmentsInstancesReportSummary.json +if __name__ == "__main__": + main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_delete.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_delete.py index 30432958be62..20f391e482ed 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_delete.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableOperationDelete.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationDelete.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_get.py index eb5a953d3cbe..e9cc81e2c8b9 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableOperationGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_list.py index 0f909ffff25e..b8596e1e79cb 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableOperationList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_patch.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_patch.py index fab4318cc920..bfeb6c21821b 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_patch.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableOperationPatch.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPatch.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put.py index 338a2dda87c7..1e311f5573ac 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableOperationPut.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPut.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put_or_patch_acls.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put_or_patch_acls.py index dbf195015be1..d842ace68060 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put_or_patch_acls.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_operation_put_or_patch_acls.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableOperationPutOrPatchAcls.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPutOrPatchAcls.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_services_get.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_services_get.py index 6bdb974efb0b..e7042624a211 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_services_get.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_services_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableServicesGet.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesGet.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_services_list.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_services_list.py index ae80e7c298eb..b45d936c56b4 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_services_list.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_services_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableServicesList.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesList.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/generated_samples/table_services_put.py b/sdk/storage/azure-mgmt-storage/generated_samples/table_services_put.py index 215402cb4b20..86604df737ad 100644 --- a/sdk/storage/azure-mgmt-storage/generated_samples/table_services_put.py +++ b/sdk/storage/azure-mgmt-storage/generated_samples/table_services_put.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.storage import StorageManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/TableServicesPut.json +# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesPut.json if __name__ == "__main__": main() diff --git a/sdk/storage/azure-mgmt-storage/setup.py b/sdk/storage/azure-mgmt-storage/setup.py index b26195b2d4a3..ba4ee4bc7567 100644 --- a/sdk/storage/azure-mgmt-storage/setup.py +++ b/sdk/storage/azure-mgmt-storage/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,9 @@ "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", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )